Changeset 438
- Timestamp:
- 04/28/08 17:15:07 (9 months ago)
- Location:
- trunk/app
- Files:
-
- 12 modified
-
config/sql/postgresql/treasures_vclassrooms.sql (modified) (1 diff)
-
controllers/helps_controller.php (modified) (3 diffs)
-
controllers/images_controller.php (modified) (7 diffs)
-
controllers/tests_controller.php (modified) (1 diff)
-
controllers/treasures_controller.php (modified) (5 diffs)
-
models/treasure.php (modified) (2 diffs)
-
views/helps/admin_edit.ctp (modified) (2 diffs)
-
views/images/admin_add.ctp (modified) (1 diff)
-
views/images/admin_listing.ctp (modified) (1 diff)
-
views/treasures/admin_edit.ctp (modified) (1 diff)
-
views/treasures/admin_listing.ctp (modified) (1 diff)
-
webroot/img/imgusers/aarkerio_12.jpg (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/config/sql/postgresql/treasures_vclassrooms.sql
r436 r438 1 1 --HABTM 2 2 CREATE TABLE "treasures_vclassrooms" ( 3 "treasure_id" int NOT NULL REFERENCES treasures(id), 4 "vclassroom_id" int NOT NULL REFERENCES vclassrooms(id), 5 PRIMARY KEY ("vclassroom_id", "treasure_id") 3 "id" serial PRIMARY KEY, 4 "treasure_id" int NOT NULL REFERENCES treasures(id) ON DELETE CASCADE, 5 "vclassroom_id" int NOT NULL REFERENCES vclassrooms(id) ON DELETE CASCADE, 6 UNIQUE ("treasure_id", "vclassroom_id") 6 7 ); 7 8 -
trunk/app/controllers/helps_controller.php
r435 r438 8 8 * @package Karamelo 9 9 */ 10 // file : app/controller/ faqs_controller.php10 // file : app/controller/helps_controller.php 11 11 12 12 uses('sanitize'); … … 118 118 if (!empty($this->data['Help'])) 119 119 { 120 //die(debug($this->data['Help'])); 120 121 $this->Sanitize = new Sanitize; 121 122 … … 126 127 $this->Help->create(); 127 128 128 if ($this->Help->save($this->data['Help']))129 {130 $id = $this->Help->getLastInsertID();129 if ($this->Help->save($this->data['Help'])) 130 { 131 $id = $this->Help->getLastInsertID(); 131 132 $this->msgFlash('Help saved','/admin/helps/edit/'.$id); 132 }133 } 133 134 } 134 135 } -
trunk/app/controllers/images_controller.php
r394 r438 8 8 * @package Karamelo 9 9 */ 10 // file : app/controller/faqs_controller.php 10 // file : app/controller/images_controller.php 11 11 12 uses('sanitize'); 12 13 13 14 class ImagesController extends AppController 14 15 { 15 public $helpers = array('Ajax' , 'User');16 16 public $helpers = array('Ajax'); 17 17 18 public $components = array('Adds'); 18 19 19 20 public function isAuthorized() 20 21 { … … 28 29 return false; // go away !! 29 30 } 30 31 public function index($id = null) 32 { 33 $this->pageTitle = 'View Active Users'; 34 $this->set('data', $this->User->findAll()); 35 $this->set('color', 'blue'); 36 } 37 /*** 38 === ADMIN METHODS 39 ***/ 40 public function admin_listing($set = null) 41 { 31 32 /*** === ADMIN METHODS ***/ 33 34 public function admin_listing($set = null) 35 { 42 36 // $set defines if display in admin layout or in small popup window 43 37 if ($set == null) … … 62 56 $order = "Image.id DESC"; 63 57 64 $data = $this->Image->findAll($conditions, $fields, $order, $limit); 65 66 $this->set('data', $data); 67 } 68 69 public function admin_add($type = null) 70 { 71 72 //die(print_r($this->data)); 73 58 $this->set('data', $this->Image->findAll($conditions, $fields, $order, $limit)); 59 } 60 61 public function admin_add($set = null) 62 { 63 64 //die(debug($this->data)); 65 66 if ($this->data['Image']['file']['error'] == 1) 67 { 68 $this->flash('Error uploading image, please contact the support team', '/admin/images/listing'); 69 } 70 74 71 $this->layout = 'admin'; 75 72 … … 92 89 /** uploaddir: directory relative to where script is running */ 93 90 94 if ( isset($type) && $type == 'avatar') // avatar or user image? 95 { 96 $uploaddir = "../webroot/img/avatars"; 97 } 98 else 99 { 100 $uploaddir = "../webroot/img/imgusers"; 101 } 91 $uploaddir = "../webroot/img/imgusers"; 102 92 103 93 $maxfilesize = 2097152; /** 2MB max size */ … … 127 117 if ( $imgfile_size > $maxfilesize) 128 118 { 129 $ErrMsg = "<h1>ERROR</h1> The image is too big.<br>";119 $ErrMsg = "<h1>ERROR</h1> The image is too big.<br>"; 130 120 $ErrMsg .= "<p>Bigger than 2.0 MB <br><br>"; 131 121 $ErrMsg .= "Current size: " . $imgfile_size ."</p>\n"; … … 163 153 } 164 154 } 165 166 /*** Create thumb***/ 167 if ( $type != 'avatar') 168 { 169 $this->createThumb($final_filename); 170 } 155 156 /** made thumb **/ 157 $this->createThumb($final_filename); 158 171 159 /** Database stuff **/ 172 160 … … 179 167 { 180 168 $this->redirect($this->data['Image']['return']); //go back to display gallery 181 exit();182 169 } 183 170 -
trunk/app/controllers/tests_controller.php
r431 r438 162 162 } 163 163 164 private function chk($user_id) // preview tests before send 164 private function chk($user_id) // preview tests before send, this method is for 0.3 version 165 165 { 166 166 try { -
trunk/app/controllers/treasures_controller.php
r437 r438 5 5 * GPLv3 manuel<at>mononeurona<dot>org 6 6 */ 7 //File: /app/controllers/treasures_controller.php 8 9 7 10 uses('sanitize'); 11 uses('L10n'); 8 12 9 13 class TreasuresController extends AppController { … … 19 23 if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2 ) // admin and teachers 20 24 { 21 return true;25 return true; 22 26 } 23 27 } … … 91 95 } 92 96 93 public function admin_add() 94 { 97 public function admin_vclassrooms($treasure_id) 98 { 99 $this->pageTitle = $this->Auth->user('username') . '\'s Treasure'; 100 101 $this->layout = 'admin'; 102 103 $conditions = array('Vclassroom.user_id'=>$this->Auth->user('id'), 'Vclassroom.status'=>1); 104 105 $this->set('data', $this->Treasure->Vclassroom->findAll($conditions)); 106 107 $this->Treasure->unbindModel(array('belongsTo'=>array('User'))); 108 109 $this->set('treasures',$this->Treasure->TreasuresVclassroom->findAll(array('TreasuresVclassroom.treasure_id' => $treasure_id))); 110 111 $this->set('treasure_id', $treasure_id); 112 } 113 114 public function admin_link2class() 115 { 116 $this->layout = 'admin'; 117 // add to database 118 if ( !empty($this->data['TreasuresVclassroom']) ) 119 { 120 $this->Sanitize = new Sanitize; 121 122 $this->Sanitize->clean($this->data['TreasuresVclassroom']); 123 124 $this->Treasure->TreasuresVclassroom->create(); 125 126 if ( $this->Treasure->TreasuresVclassroom->save($this->data['TreasuresVclassroom'])) 127 { 128 $this->msgFlash('Treasure assigned', '/admin/treasures/vclassrooms/'.$this->data['TreasuresVclassroom']['treasure_id']); 129 } 130 else 131 { 132 die('Something is wrong, please report this bug'); 133 } 134 } 135 } 136 137 public function admin_unlink2class() 138 { 139 $this->layout = 'admin'; 140 // add to database 141 if ( !empty($this->data['TreasuresVclassroom']) ) 142 { 143 $this->Sanitize = new Sanitize; 144 145 $this->Sanitize->clean($this->data['TreasuresVclassroom']); 146 147 if ( $this->Treasures->TreasuresVclassroom->delete($this->data['TreasuresVclassroom']['id'])) 148 { 149 $this->msgFlash('Test unlinked', '/admin/tests/vclassrooms/'.$this->data['TreasuresVclassroom']['treasure_id']); 150 } 151 else 152 { 153 die('Something is wrong, please report this bug'); 154 } 155 } 156 } 157 158 public function admin_add() 159 { 95 160 $this->layout = 'admin'; 96 161 // adds new blog entries 97 162 if ( !empty($this->data['Treasure']) ) 98 {99 $this->Sanitize = new Sanitize;100 163 { 164 $this->Sanitize = new Sanitize; 165 101 166 $this->Sanitize->html($this->data["Treasure"]["title"]); 102 167 103 168 $this->Sanitize->html($this->data["Treasure"]["instructions"]); 104 169 … … 109 174 if ($this->Treasure->save($this->data['Treasure'])) 110 175 { 111 $id = $this->Treasure->getLastInsertId();112 $this->msgFlash('Treasure registered', '/admin/treasures/edit/'.$id);176 $id = $this->Treasure->getLastInsertId(); 177 $this->msgFlash('Treasure saved', '/admin/treasures/edit/'.$id); 113 178 } 114 179 else … … 162 227 } 163 228 164 public function admin_delete($id) 165 { 166 $this->Treasure->del($id); 167 168 $this->msgFlash('Treasure deleted', '/admin/treasures/listing'); 169 } 229 public function admin_delete() 230 { 231 if ($this->Treasure->del($this->data['Treasure']['id'])) 232 { 233 $this->msgFlash('Treasure deleted', '/admin/treasures/listing'); 234 } 235 } 170 236 } 171 237 ?> -
trunk/app/models/treasure.php
r162 r438 1 1 <?php 2 /** Chipotle Software 2002-2007 GPLv3 **/ 2 /** 3 * Karamelo eLearning Platform 4 * Chipotle Software 2002-2008 5 * GPLv3 manuel<arroba>mononeurona<punto>org 6 **/ 7 3 8 class Treasure extends AppModel { 4 9 … … 6 11 7 12 public $belongsTo = 'User'; 8 13 14 public $hasAndBelongsToMany = array('Vclassroom' => 15 array('className' => 'Vclassroom', 16 'joinTable' => 'treasures_vclassrooms', 17 'foreignKey' => 'treasure_id', 18 'associationForeignKey' => 'vclassroom_id', 19 'conditions' => null, 20 'order' => null, 21 'limit' => '', 22 'unique' => true, 23 'finderQuery' => '', 24 'deleteQuery' => '' 25 ) 26 ); 27 9 28 public $validate = array( 10 29 'user_id' => VALID_NOT_EMPTY, -
trunk/app/views/helps/admin_edit.ctp
r435 r438 15 15 <tr> 16 16 <td> 17 <?php echo $ html->input('Help.url', array("size" => 30, "maxlength" => 100)); ?>17 <?php echo $form->input('Help.url', array("size" => 30, "maxlength" => 100)); ?> 18 18 19 19 </td> 20 20 <td> 21 21 <?php 22 echo $form->labe ('Help.lang', 'Lang:') .'<br />';22 echo $form->label('Help.lang', 'Lang:') .'<br />'; 23 23 $langs = array("en"=>"English", "es"=>"Espanol", "fr"=>"Francaise", "de"=>"Deutschland", "af"=>"Afrikaans", "id"=>"Indonesian"); 24 24 echo $form->select('Help.lang', $langs, null, null, null, false); … … 33 33 <tr><td colspan="3"> 34 34 <?php 35 echo $form->label('Help.help', 'Help:' );36 echo $form->textarea('Help.help', array('cols'=>80, 'rows'=>25)) 37 echo $fck->load('HelpHelp', 'Karamelo', 700, 300);35 echo $form->label('Help.help', 'Help:'); 36 echo $form->textarea('Help.help', array('cols'=>80, 'rows'=>25)); 37 echo $fck->load('HelpHelp', 'Karamelo', 700, 600); 38 38 ?> 39 39 </td></tr> 40 40 41 41 <tr> 42 <td colspan="3"><?php echo $form->label( 'Help.end', 'End edition:' ); echo$form->checkbox('Help.end', array('value'=>1)); ?></td>42 <td colspan="3"><?php echo $form->label( 'Help.end', 'End edition:') . $form->checkbox('Help.end', array('value'=>1)); ?></td> 43 43 </tr> 44 44 <tr><td colspan="3"> -
trunk/app/views/images/admin_add.ctp
r268 r438 1 <?php echo $javascript->link('myfunctions'); ?> 2 3 <div class="title_section">Add new image</div> 4 5 <div class="spaced"> 6 7 <?php echo $html->formTag('/images/add/','post', array("enctype"=>"multipart/form-data") ); ?> 8 <?php echo $html->hiddenTag('Image/user_id', $othAuth->user('id')); ?> 9 <?php echo $html->hiddenTag('return', '/users/edit'); ?> 1 <?php 2 echo $javascript->link('myfunctions'); 3 4 echo $html->div('title_section', 'Add new image'); 5 6 echo $form->create('Image', array("enctype"=>"multipart/form-data") ); 7 echo $form->hidden('return', array('value'=>'/admin/images/listing')); 8 ?> 10 9 11 10 <fieldset> 12 11 <legend>Image</legend> 13 14 <p> 15 <?php echo $form->labelTag( 'Image/file', 'Title:' );?><br /> 16 <?php echo $html->file('Image/file'); ?> 17 <?php echo $html->tagErrorMsg('Image/file', 'Title is required.'); ?> 18 19 <br /> 20 <?php echo $html->submit('Upload'); ?> 12 <?php 13 echo $form->label( 'Image.file', 'Title:' ); 14 echo $form->file('Image.file'); 15 echo $form->end('Upload'); 16 ?> 21 17 </fieldset> 22 </form> 23 </div> 18 -
trunk/app/views/images/admin_listing.ctp
r375 r438 19 19 <td style="text-align:left;" colspan="5"> 20 20 <?php 21 echo $form->create('Image', array(' action'=>'add', 'enctype'=>'multipart/form-data'));21 echo $form->create('Image', array('enctype'=>'multipart/form-data')); 22 22 echo $form->hidden('Image.return', array('value'=>'/admin/images/listing/'.$return)); 23 23 ?> 24 24 <fieldset> 25 <legend> Upload Image</legend>25 <legend><?php echo __('Upload Image'); ?></legend> 26 26 27 <?php echo $form->label('Image.file', 'File:' );27 <?php echo $form->label('Image.file', 'File:'); 28 28 echo $form->file('Image.file'); 29 echo $form->error('Image.file', 'Title is required.'); 30 echo '</fieldset>'; 29 echo $form->error('Image.file', 'File is required.'); 31 30 echo $form->end('Upload'); 32 31 ?> 32 </fieldset> 33 33 </td> 34 34 </tr> -
trunk/app/views/treasures/admin_edit.ctp
r437 r438 2 2 3 3 echo $html->addCrumb('Control Tools', '/admin/entries/start'); 4 echo $html->addCrumb(' News', '/admin/treasures/listing');4 echo $html->addCrumb('Treasures', '/admin/treasures/listing'); 5 5 echo $html->getCrumbs(' / '); 6 6 echo $form->create('Treasure',array('onsubmit'=>'return chkForm()')); -
trunk/app/views/treasures/admin_listing.ctp
r437 r438 17 17 echo $html->div('butonright', $gags->sendEdit($val['Treasure']['id'], 'treasures')); 18 18 echo $html->div('div_title', $val['Treasure']['title']); 19 echo $html->para(null, '<b>Treasure description:</b> '.$val['Treasure']['description']);20 19 21 echo $html->link('Questions', '/admin/treasures/questions/'.$val['Treasure']['id']);22 echo $html->link($html->image('admin/questions_icon.gif', array('alt'=>'Questions', 'title'=>'Questions')),23 '/admin/treasures/questions/'.$val['Treasure']['id'], null, null, false) . '<br />';24 20 if ( count($val['Vclassroom']) < 1 ) 25 21 {
