Changeset 301
- Timestamp:
- 03/03/08 21:41:31 (10 months ago)
- Location:
- trunk/app
- Files:
-
- 17 modified
-
config/sql/karamelo_postgres.sql (modified) (1 diff)
-
controllers/ecourses_controller.php (modified) (6 diffs)
-
controllers/entries_controller.php (modified) (1 diff)
-
controllers/news_controller.php (modified) (5 diffs)
-
controllers/vclassrooms_controller.php (modified) (9 diffs)
-
views/ecourses/admin_add.ctp (modified) (2 diffs)
-
views/ecourses/admin_listing.ctp (modified) (1 diff)
-
views/ecourses/admin_vclassrooms.ctp (modified) (1 diff)
-
views/entries/admin_add.ctp (modified) (1 diff)
-
views/entries/admin_edit.ctp (modified) (3 diffs)
-
views/entries/admin_listing.ctp (modified) (1 diff)
-
views/helpers/gags.php (modified) (2 diffs)
-
views/news/admin_add.ctp (modified) (2 diffs)
-
views/news/admin_edit.ctp (modified) (2 diffs)
-
views/news/admin_listing.ctp (modified) (1 diff)
-
views/vclassrooms/admin_add.ctp (modified) (2 diffs)
-
webroot/js/fckeditor/fckconfig.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/config/sql/karamelo_postgres.sql
r290 r301 313 313 "code" varchar(15), -- secret code to allow students join to the ecourse, voM121x for instance 314 314 "created" timestamp(0) with time zone DEFAULT now() NOT NULL, 315 "status" smallint DEFAULT 0 NOT NULL, 315 316 "lang_id" int NOT NULL REFERENCES langs(id) 316 317 ); -
trunk/app/controllers/ecourses_controller.php
r247 r301 10 10 class EcoursesController extends AppController 11 11 { 12 public $helpers = array('Fck', 'Gags');12 public $helpers = array('Fck', 'Gags', 'Paginator'); 13 13 14 public $components = array('Pagination'); 14 public function isAuthorized() 15 { 16 if (isset( $this->params[Configure::read('Routing.admin')] )) 17 { 18 if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2 ) // admin and teachers 19 { 20 return true; 21 } 22 } 23 return false; // go away !! 24 } 15 25 16 public function isAuthorized() 17 { 18 if ($this->action == 'delete') 19 { 20 if ($this->Auth->user('group_id') == 1) 21 { 22 return true; 23 } else { 24 return false; 25 } 26 } 27 28 return true; 29 } 30 31 /**** 26 /**** 32 27 ===== ADMIN SECTION ========== 33 ****/34 public function admin_start()28 ****/ 29 public function admin_start() 35 30 { 36 31 $this->layout = 'admin'; 37 32 38 33 39 $conditions = array("user_id"=>$this-> othAuth->user('id'));34 $conditions = array("user_id"=>$this->Auth->user('id')); 40 35 $fields = array('id', 'title', 'access', 'status', 'code', 'description'); 41 36 $order = "Ecourse.title DESC"; … … 47 42 $this->layout = 'admin'; 48 43 49 //pagination 50 //$total_rows = $this->Ecourse->findCount(array("user_id"=>$this->othAuth->user('id'))); 51 52 $lmt = 25; // limit news 53 54 $targetpage = "/admin/news/listing/"; 55 56 // $pagination = $this->Mypagination->init($total_rows, $page, $lmt, $targetpage); //Pagination 57 58 // $this->set('pagination', $pagination); 59 60 61 $conditions = array("user_id"=>$this->othAuth->user('id')); 62 $fields = array('id', 'title', 'access', 'status', 'code', 'description'); 44 $conditions = array("user_id"=>$this->Auth->user('id')); 45 $fields = array('id', 'title', 'status', 'code', 'description'); 63 46 $order = "Ecourse.id DESC"; 64 $offset = (($page * $lmt) - $lmt); 65 $limit = $lmt . " OFFSET " . $offset; 47 $limit = 10; 66 48 67 49 $this->set('data', $this->Ecourse->findAll($conditions, $fields)); … … 72 54 $this->layout = 'admin'; 73 55 74 //pagination75 //$total_rows = $this->Ecourse->findCount(array("user_id"=>$this->othAuth->user('id')));76 77 56 $lmt = 25; // limit news 78 57 79 $targetpage = "/admin/news/listing/"; 80 81 // $pagination = $this->Mypagination->init($total_rows, $page, $lmt, $targetpage); //Pagination 82 83 // $this->set('pagination', $pagination); 58 $conditions = array("Ecourse.user_id"=>$this->Auth->user('id'), "Ecourse.id"=>$ecourse_id); 59 $fields = array('id', 'title', 'status', 'code'); 60 $order = "Ecourse.id DESC"; 84 61 85 86 $conditions = array("Ecourse.user_id"=>$this->othAuth->user('id'), "Ecourse.id"=>$ecourse_id);87 $fields = array('id', 'title', 'access', 'status', 'code');88 $order = "Ecourse.id DESC";89 //$offset = (($page * $lmt) - $lmt);90 //$limit = $lmt . " OFFSET " . $offset;91 92 62 $this->set('data', $this->Ecourse->find($conditions, $fields)); 93 63 } 94 64 95 65 public function admin_add() 96 { 97 66 { 98 67 $this->layout = 'admin'; 99 68 … … 102 71 $this->Sanitize = new Sanitize; 103 72 104 $this->Sanitize->clean Array($this->data["Ecourse"]);73 $this->Sanitize->clean($this->data["Ecourse"]); 105 74 106 $this->data['Ecourse']['user_id'] = $this-> othAuth->user('id');75 $this->data['Ecourse']['user_id'] = $this->Auth->user('id'); 107 76 108 77 $this->Ecourse->create(); … … 112 81 $this->msgFlash('Course saved', '/admin/ecourses/listing'); 113 82 } 114 }83 } 115 84 else 116 85 { 117 $this->set('subjects', $this->Ecourse->Subject->generateList(null, 'title')); 118 119 $this->set('langs', $this->Ecourse->Lang->generateList(null, 'lang', null, '{n}.Lang.id', '{n}.Lang.lang')); 86 87 $this->set('subjects', Set::combine($this->Ecourse->Subject->find('all', array('order' => 'title')), "{n}.Subject.id","{n}.Subject.title")); 88 89 $this->set('langs', Set::combine($this->Ecourse->Lang->find('all', array('order' => 'lang')), "{n}.Lang.id","{n}.Lang.lang")); 90 120 91 } 121 92 } … … 167 138 } 168 139 /*** DELETE **/ 169 public function admin_delete($id)170 {140 public function admin_delete($id) 141 { 171 142 $this->Ecourse->del($id); 172 143 173 144 $this->msgFlash('Course deleted', '/admin/ecourses/listing'); 174 }145 } 175 146 } 176 147 ?> -
trunk/app/controllers/entries_controller.php
r292 r301 73 73 public function admin_add() 74 74 { 75 $this->layout = 'admin';75 $this->layout = 'admin'; 76 76 77 $this->set('subjects', Set::combine($this->Entry->Subject->find('all', array('order' => 'title')), "{n}.Subject.id","{n}.Subject.title"));77 $this->set('subjects', Set::combine($this->Entry->Subject->find('all', array('order' => 'title')), "{n}.Subject.id","{n}.Subject.title")); 78 78 79 79 if ( !empty($this->data["Entry"]) ) -
trunk/app/controllers/news_controller.php
r275 r301 3 3 * Karamelo E-Learning Platform 4 4 * Manuel Montoya 2002-2008 5 * GPL License manuel<at>mononeurona<punto>org5 * GPLv3 License manuel<at>mononeurona<punto>org 6 6 * Chipotle Software 7 7 */ … … 19 19 if (isset($this->params[Configure::read('Routing.admin')])) 20 20 { 21 if ($this->Auth->user('group_id') != 1)21 if ($this->Auth->user('group_id') == 1) 22 22 { 23 return false;23 return true; 24 24 } 25 25 } 26 return true;26 return false; 27 27 } 28 28 … … 120 120 public function admin_listing($page=1) 121 121 { 122 //pagination 123 $total_rows = $this->News->findCount(array("user_id"=>$this->othAuth->user('id'))); 124 125 $lmt = 25; // limit news 126 127 $targetpage = "/admin/news/listing/"; 128 129 $pagination = $this->Mypagination->init($total_rows, $page, $lmt, $targetpage); //Pagination 130 131 $this->set('pagination', $pagination); 132 133 $this->pageTitle = $this->othAuth->user('username') . '\'s News'; 134 135 $this->layout = 'admin'; 136 137 $conditions = array("News.user_id" => $this->othAuth->user('id') ); // only the user's news 138 $fields = array("id", "title", "body", "created", "reference", "status", "theme_id", "user_id"); 139 $order = "News.id DESC"; 140 141 $offset = (($page * $lmt) - $lmt); 142 143 $limit = $lmt . " OFFSET " . $offset; 144 145 $this->set('data', $this->News->findAll($conditions, $fields, $order, $limit)); 122 $this->pageTitle = 'News manager'; 123 124 $this->layout = 'admin'; 125 126 $conditions = array("News.user_id" => $this->Auth->user('id') ); // only the user's news 127 $fields = array("id", "title", "body", "created", "reference", "status", "theme_id", "user_id"); 128 $order = "News.id DESC"; 129 $limit = 20; 130 131 $this->set('data', $this->News->findAll($conditions, $fields, $order, $limit)); 146 132 } 147 133 … … 162 148 { 163 149 $this->layout = 'admin'; 164 165 $this->set(' themes', $this->News->Theme->generateList(null, 'theme ASC', null, '{n}.Theme.id', '{n}.Theme.theme'));150 151 $this->set('subjects',Set::combine($this->News->Theme->find('all', array('order'=>'title')),"{n}.Subject.id","{n}.Subject.title")); 166 152 167 153 if (!empty($this->data["News"])) … … 179 165 $this->data["News"]["body"] = utf8_encode($tmp); 180 166 181 $this->data["News"]["user_id"] = $this-> othAuth->user('id');167 $this->data["News"]["user_id"] = $this->Auth->user('id'); 182 168 183 169 if ($this->News->save($this->data["News"])) -
trunk/app/controllers/vclassrooms_controller.php
r247 r301 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) 21 { 22 return false; 23 } 24 } 25 return true; 26 } 27 28 18 if (isset($this->params[Configure::read('Routing.admin')])) 19 { 20 if ($this->Auth->user('group_id') == 1) 21 { 22 return true; 23 } 24 } 25 return false; 26 } 27 29 28 public function show($user_id, $id) 30 29 { … … 61 60 else 62 61 { 63 if ($this->Vclassroom->addAssoc('User', $this-> othAuth->user('id'), $this->data["Vclassroom"]["vclassroom_id"]))62 if ($this->Vclassroom->addAssoc('User', $this->Auth->user('id'), $this->data["Vclassroom"]["vclassroom_id"])) 64 63 { 65 64 $this->set('msg', 'You have joined to this class succesfully!'); … … 82 81 foreach ($data['User'] as $user) 83 82 { 84 if ($user['id'] == $this-> othAuth->user('id'))83 if ($user['id'] == $this->Auth->user('id')) 85 84 { 86 85 $already_member = true; // yes, is already member … … 99 98 { 100 99 $this->layout = 'admin'; 101 $conditions = array("Vclassroom.user_id"=>$this-> othAuth->user('id'));100 $conditions = array("Vclassroom.user_id"=>$this->Auth->user('id')); 102 101 $fields = array("Vclassroom.id", "Vclassroom.name", "Vclassroom.created", "Vclassroom.user_id", "Vclassroom.ecourse_id"); 103 102 $order = "Vclassroom.id DESC"; … … 112 111 $this->layout = 'admin'; 113 112 114 $conditions = array("Vclassroom.user_id"=>$this-> othAuth->user('id'), "Vclassroom.id"=>$vclassroom_id);113 $conditions = array("Vclassroom.user_id"=>$this->Auth->user('id'), "Vclassroom.id"=>$vclassroom_id); 115 114 116 115 $this->pageTitle = 'Class members'; … … 123 122 $this->layout = 'popup'; 124 123 125 $conditions = array("Vclassroom.user_id"=>$this-> othAuth->user('id'), "Vclassroom.id"=>$vclassroom_id);124 $conditions = array("Vclassroom.user_id"=>$this->Auth->user('id'), "Vclassroom.id"=>$vclassroom_id); 126 125 127 126 $this->pageTitle = 'Tests'; 128 127 129 128 $this->set('data', $this->Vclassroom->find($conditions)); 130 $this->set('test', $this->Vclassroom->Test->findAll(array("Test.user_id"=>$this-> othAuth->user('id'), "Test.status"=>1)));129 $this->set('test', $this->Vclassroom->Test->findAll(array("Test.user_id"=>$this->Auth->user('id'), "Test.status"=>1))); 131 130 } 132 131 // link webquest to classroom … … 135 134 $this->layout = 'popup'; 136 135 137 $conditions = array("Vclassroom.user_id"=>$this-> othAuth->user('id'), "Vclassroom.id"=>$vclassroom_id);136 $conditions = array("Vclassroom.user_id"=>$this->Auth->user('id'), "Vclassroom.id"=>$vclassroom_id); 138 137 139 138 $this->pageTitle = 'Webquest'; 140 139 141 140 $this->set('data', $this->Vclassroom->find($conditions)); 142 $this->set('webquest', $this->Vclassroom->Webquest->findAll(array("Webquest.user_id"=>$this-> othAuth->user('id'), "Webquest.status"=>1)));141 $this->set('webquest', $this->Vclassroom->Webquest->findAll(array("Webquest.user_id"=>$this->Auth->user('id'), "Webquest.status"=>1))); 143 142 } 144 143 // link treasure to classroom … … 147 146 $this->layout = 'popup'; 148 147 149 $conditions = array("Vclassroom.user_id"=>$this-> othAuth->user('id'), "Vclassroom.id"=>$vclassroom_id);148 $conditions = array("Vclassroom.user_id"=>$this->Auth->user('id'), "Vclassroom.id"=>$vclassroom_id); 150 149 151 150 $this->pageTitle = 'Treasure'; 152 151 153 152 $this->set('data', $this->Vclassroom->find($conditions)); 154 $this->set('treasure', $this->Vclassroom->Treasure->findAll(array("Treasure.user_id"=>$this-> othAuth->user('id'), "Treasure.status"=>1)));153 $this->set('treasure', $this->Vclassroom->Treasure->findAll(array("Treasure.user_id"=>$this->Auth->user('id'), "Treasure.status"=>1))); 155 154 } 156 155 public function admin_start($vclassroom_id) 157 156 { 158 157 $this->layout = 'admin'; 159 $conditions = array("Vclassroom.user_id"=>$this-> othAuth->user('id'), "Vclassroom.id"=>$vclassroom_id);158 $conditions = array("Vclassroom.user_id"=>$this->Auth->user('id'), "Vclassroom.id"=>$vclassroom_id); 160 159 $fields = array("Vclassroom.id", "Vclassroom.name", "Vclassroom.order", "Vclassroom.created", "Vclassroom.user_id", "Vclassroom.subject_id"); 161 160 $order = "Vclassroom.id DESC"; … … 174 173 $this->Sanitize->cleanArray($this->data["Vclassroom"]); 175 174 176 $this->data["Vclassroom"]["user_id"] = $this-> othAuth->user('id');175 $this->data["Vclassroom"]["user_id"] = $this->Auth->user('id'); 177 176 178 177 $this->Vclassroom->create(); -
trunk/app/views/ecourses/admin_add.ctp
r268 r301 1 <?php echo $ html->formTag('/admin/ecourses/add','post', array("onsubmit"=>"return chkForm();"));?>1 <?php echo $form->create('Ecourse', array('action'=>'admin_add', 'onsubmit'=>'return chkForm()')); ?> 2 2 <fieldset> 3 3 <legend>New Course</legend> 4 <p>By default, your course is accessible to everybody. If you want some c0onfidentiality, 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 <?php 6 echo $form->labelTag('Ecourse/title', 'Title:'); 7 echo $html->input('Ecourse/title', array("size" => 30, "maxlength" => 90)) . ' e.g. History of Literature'; 8 echo $html->tagErrorMsg('Ecourse/title', 'A FAQ title is required.'); 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 <?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.'); 9 8 10 echo $form->labelTag('Ecourse/description', 'Description:');11 echo $html->textarea('Ecourse/description', array("cols" => 40, "rows" =>4));9 echo $form->label('Ecourse.description', 'Description:'); 10 echo $form->textarea('Ecourse.description', array("cols" => 40, "rows" =>4)); 12 11 13 14 echo $form->labelTag('Ecourse/code', 'Code:' ); 15 echo $html->input('Ecourse/code', array("size" => 12, "maxlenght" => 12)) . ' max. 12 characters, ie.ROM2121'; 16 echo $html->tagErrorMsg('Ecourse/code', 'A category description is required.'); 17 ?> 18 <br /><br /> 19 <?php 20 echo $form->labelTag('Ecourse/subject_id', 'Subject:'); 21 echo $html->selectTag('Ecourse/subject_id', $subjects, null, null, null, false); 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.'); 14 15 echo $form->label('Ecourse.subject_id', 'Subject:'); 16 echo $form->select('Ecourse.subject_id', $subjects, null, null, null, false); 22 17 23 echo $form->labelTag('Ecourse/lang_id', 'Lang:');24 echo $html->selectTag('Ecourse/lang_id', $langs, null, null, null, false);18 echo $form->label('Ecourse.lang_id', 'Lang:'); 19 echo $form->select('Ecourse.lang_id', $langs, null, null, null, false); 25 20 ?> 26 21 27 22 <div style="clear:both"></div> 28 23 <br /> 29 <?php echo $ html->submit('Save')?>24 <?php echo $form->end('Save'); ?> 30 25 </fieldset> 31 </form> 26 32 27 <script type="text/javascript"> 33 28 /* <![CDATA[ */ … … 39 34 { 40 35 Div.style.display = "block"; 41 }42 else43 {36 } 37 else 38 { 44 39 Div.style.display = "none"; 45 }40 } 46 41 } 47 42 -
trunk/app/views/ecourses/admin_listing.ctp
r268 r301 1 <?php2 if ( isset($javascript) ):3 echo $html->charsetTag('UTF-8');4 echo $javascript->link('prototype');5 echo $javascript->link('scriptaculous.js?load=effects');6 endif;7 ?>8 1 <script type="text/javascript"> 9 2 window.onload = timedMsg; -
trunk/app/views/ecourses/admin_vclassrooms.ctp
r268 r301 1 1 <?php 2 2 //exit(print_r($data)); 3 4 if ( isset($javascript) ):5 echo $html->charsetTag('UTF-8');6 echo $javascript->link('prototype');7 echo $javascript->link('scriptaculous.js?load=effects');8 endif;9 3 10 4 echo $html->addCrumb('Control Tools', '/admin/entries/start'); -
trunk/app/views/entries/admin_add.ctp
r292 r301 32 32 <?php 33 33 echo $form->label( 'Entry.Body', 'Body:' ); 34 echo $form->textarea('Entry /body', array("cols"=>80, "rows"=>30));35 echo $fck->load('Entry /body', 'Karamelo');36 echo $form->error('Entry /body', 'Body is required.');34 echo $form->textarea('Entry.body', array("cols"=>80, "rows"=>30)); 35 echo $fck->load('EntryBody', 'Default'); 36 echo $form->error('Entry.body', 'Body is required.'); 37 37 ?> 38 38 </td></tr> -
trunk/app/views/entries/admin_edit.ctp
r292 r301 38 38 <td colspan="3"> 39 39 <?php 40 echo $form->label('Entry. Body', 'Body:');40 echo $form->label('Entry.body', 'Body:'); 41 41 echo $form->textarea('Entry.body', array("cols"=>80, "rows"=>22)); 42 echo $fck->load('EntryBody', ' Karamelo');42 echo $fck->load('EntryBody', 'Default'); 43 43 echo $form->error('Entry.body', 'Body is required.'); 44 44 ?> … … 47 47 <td> 48 48 <?php 49 echo $form->label( 'Entry/status', 'Published:' );49 echo $form->label('Entry/status', 'Published:' ); 50 50 echo $form->checkbox('Entry/status', null, array("value" => 1)); 51 51 ?> … … 53 53 <td> 54 54 <?php 55 echo $form->label( 'Entry.discution', 'Comments allowed:' );55 echo $form->label('Entry.discution', 'Comments allowed:' ); 56 56 echo $form->checkbox('Entry.discution', null, array("value" => 1)); 57 57 ?> -
trunk/app/views/entries/admin_listing.ctp
r276 r301 30 30 foreach ($data as $val) { 31 31 $tr = array ( 32 $gags->sendEdit($val['Entry']['id'], ' entries'),32 $gags->sendEdit($val['Entry']['id'], 'Entry'), 33 33 $val['Entry']['title'], 34 34 $gags->setStatus($val['Entry']['status']), 35 $gags->confirmDel($val['Entry']['id'], ' entries')35 $gags->confirmDel($val['Entry']['id'], 'Entry') 36 36 ); 37 37 -
trunk/app/views/helpers/gags.php
r276 r301 12 12 public $helpers = array('Html', 'Ajax', 'Form'); 13 13 14 public function confirmDel($id, $ controller)14 public function confirmDel($id, $model) 15 15 { 16 16 17 $strB = $this->Form->create( null, array('action'=>'/admin/'.$controller.'/delete/'.$id, "onsubmit"=>"return confirm('Are you sure to delete?')"));17 $strB = $this->Form->create($model, array('action'=>'/admin_delete/'.$id, "onsubmit"=>"return confirm('Are you sure to delete?')")); 18 18 $strB .= $this->Form->end('Delete'); 19 19 … … 21 21 } 22 22 23 public function sendEdit($id, $ controller)23 public function sendEdit($id, $model) 24 24 { 25 25 26 $strB = $this->Form->create( null, array('action'=>'/admin/'.$controller.'/edit/'.$id));26 $strB = $this->Form->create($model, array('action'=>'admin_edit/'.$id)); 27 27 $strB .= $this->Form->end('Edit'); 28 28 -
trunk/app/views/news/admin_add.ctp
r238 r301 1 <?php echo $javascript->link('prototype'); ?> 2 <?php echo $javascript->link('myfunctions'); ?> 3 <?php echo $javascript->link('poll'); ?> 4 <?php echo $javascript->link('fckeditor/fckeditor'); ?> 1 <?php 2 echo $javascript->link('myfunctions'); 3  
