Changeset 441
- Timestamp:
- 04/29/08 17:56:48 (8 months ago)
- Location:
- trunk/app
- Files:
-
- 3 added
- 10 modified
-
config/sql/postgresql/restres.sql (added)
-
config/sql/postgresql/treasures.sql (modified) (1 diff)
-
controllers/treasures_controller.php (modified) (3 diffs)
-
controllers/users_controller.php (modified) (1 diff)
-
models/result_treasure.php (added)
-
models/treasure.php (modified) (1 diff)
-
models/vclassroom.php (modified) (1 diff)
-
views/treasures/admin_add.ctp (modified) (2 diffs)
-
views/treasures/admin_edit.ctp (modified) (2 diffs)
-
views/treasures/chksw.ctp (added)
-
views/treasures/view.ctp (modified) (1 diff)
-
views/users/admin_edit.ctp (modified) (2 diffs)
-
views/vclassrooms/show.ctp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/config/sql/postgresql/treasures.sql
r436 r441 3 3 "id" serial PRIMARY KEY, 4 4 "title" varchar(150) NOT NULL, 5 "points" smallint NOT NULL DEFAULT 3, 6 "secret" varchar(15) NOT NULL, -- secret word, stop 5 7 "instructions" text NOT NULL DEFAULT '', 6 8 "user_id" int NOT NULL REFERENCES users(id) ON DELETE CASCADE, -
trunk/app/controllers/treasures_controller.php
r438 r441 16 16 17 17 public $components = array('Edublog'); 18 19 public function beforeFilter() 20 { 21 $this->Auth->allow(array('view', 'chksw')); 22 parent::beforeFilter(); 23 } 18 24 19 25 public function isAuthorized() … … 28 34 return false; // go away !! 29 35 } 36 public function chksw() 37 { 38 $this->layout = 'ajax'; 39 40 if ( !empty($this->data['ResultTreasure']) ) 41 { 42 $this->Sanitize = new Sanitize; 43 44 $this->Sanitize->clean($this->data['ResultTreasure']); 45 46 $secret = $this->Treasure->field('secret', array('status'=>1,'id'=>$this->data['ResultTreasure']['treasure_id'])); 47 48 if ( $this->data['ResultTreasure']['secret'] == $secret ) 49 { 50 $this->data['ResultTreasure']['user_id'] = $this->Auth->user('id'); 51 52 $this->Treasure->ResultTreasure->save($this->data['ResultTreasure']); 53 54 $this->set('msg', 'Cool!, the '. $this->data['ResultTreasure']['points'] .' points are yours'); 55 $this->render('chksw', 'ajax'); 56 } 57 else 58 { 59 $this->set('msg', 'Sorry, word is incorrect'); 60 $this->render('chksw', 'ajax'); 61 } 62 } 63 } 30 64 31 65 public function display($username) … … 55 89 } 56 90 57 public function view($ username, $treasure_id)91 public function view($treasure_id) 58 92 { 59 93 $conditions = array("Treasure.status"=>1, "Treasure.id"=>$treasure_id); 60 94 61 if ($username != null) 62 { 63 $user_id = $this->Treasure->User->field('id', array("username"=>$username)); 95 $data = $this->Treasure->find($conditions); 96 97 $this->layout = $this->Edublog->layout($data['Treasure']['user_id']); 98 99 $this->pageTitle = 'Treasure Hunt'; 100 101 $this->Edublog->blog($data['Treasure']['user_id']); // blogger elements 64 102 65 $conditions["user_id"] = $user_id; 66 } 67 else 68 { 69 $this->redirect('/'); // go away 70 } 71 72 $this->layout = $this->Edublog->layout($user_id); 73 74 $this->Edublog->blog($user_id); // blogger elements 75 76 $this->pageTitle = $username . '\'s Treasures'; 77 78 $this->set('data', $this->Treasure->find($conditions)); 103 $this->set('data', $data); 79 104 } 80 105 -
trunk/app/controllers/users_controller.php
r434 r441 22 22 parent::beforeFilter(); 23 23 24 if ( !empty($this->data['User'] ) )24 if ( !empty($this->data['User']['pwd']) ) 25 25 { 26 26 if ( strlen($this->data['User']['pwd']) < 5) // only if pwd is big enough -
trunk/app/models/treasure.php
r438 r441 12 12 public $belongsTo = 'User'; 13 13 14 public $hasAndBelongsToMany = array('Vclassroom' => 14 public $hasMany = array( 15 'ResultTreasure' => 16 array('className' => 'ResultTreasure', 17 'conditions' => null, 18 'foreignKey' => 'treasure_id' 19 ) 20 ); 21 22 public $hasAndBelongsToMany = array('Vclassroom' => 15 23 array('className' => 'Vclassroom', 16 24 'joinTable' => 'treasures_vclassrooms', -
trunk/app/models/vclassroom.php
r388 r441 64 64 'finderQuery' => '', 65 65 'deleteQuery' => '' 66 ), 67 'Treasure' => 68 array('className' => 'Treasure', 69 'joinTable' => 'treasures_vclassrooms', 70 'foreignKey' => 'vclassroom_id', 71 'associationForeignKey' => 'treasure_id', 72 'conditions' => '', 73 'order' => '', 74 'limit' => '', 75 'unique' => true, 76 'finderQuery' => '', 77 'deleteQuery' => '' 66 78 ) 67 79 ); -
trunk/app/views/treasures/admin_add.ctp
r437 r441 10 10 <table style="width:100%;"> 11 11 <tr> 12 <td colspan="2">12 <td> 13 13 <?php echo $form->input('Treasure.title', array("size" => 40, "maxlength" => 120)); ?> 14 </td> 15 <td> 16 <?php 17 echo $form->label('Treasure.points', 'Points:'); 18 echo $form->select('Treasure.points', array(1=>1,2=>2,3=>3,4=>4,5=>5,6=>6,7=>7,8=>8,9=>9,10=>10), 5, null, false); 19 ?> 14 20 </td> 15 21 <td> … … 25 31 26 32 </td></tr> 33 <tr><td colspan="3"> 34 <?php echo $form->input('Treasure.secret', array('size'=>15, 'maxlength'=>15, 'between'=>': ')); ?> 35 </td> 36 </tr> 37 27 38 <tr><td colspan="2"> 28 39 <?php -
trunk/app/views/treasures/admin_edit.ctp
r438 r441 10 10 <table> 11 11 <tr> 12 <td colspan="2">12 <td> 13 13 <?php echo $form->input('Treasure.title', array('size' => 40, 'maxlength' => 120)); ?> 14 14 </td> 15 <td> 16 <?php 17 echo $form->label('Treasure.points', 'Points:'); 18 echo $form->select('Treasure.points', array(1=>1,2=>2,3=>3,4=>4,5=>5,6=>6,7=>7,8=>8,9=>9,10=>10)); 19 ?> 20 </td> 15 21 <td> 16 22 <?php echo $html->link($html->image('admin/myimages.jpg', array("alt"=>"My Images", "title"=>"My Images")), '#', array("onclick"=>"javascript:window.open('/admin/images/listing/set', 'blank', 'toolbar=no, scrollbars=yes,width=700,height=500')"), null, false); ?> … … 19 25 20 26 <tr><td colspan="3"> 21 <?php echo $form->label('Treasure.intructions', 'Instructions:');?><br /> 22 <?php echo $form->textarea('Treasure.instructions', array("cols"=>80, "rows"=>25)) ?> 23 <?php echo $fck->load('TreasureInstructions', 'Karamelo'); ?> 27 <?php 28 echo $form->label('Treasure.intructions', 'Instructions:'); 29 echo $form->textarea('Treasure.instructions', array("cols"=>80, "rows"=>25)); 30 echo $fck->load('TreasureInstructions', 'Karamelo'); 31 ?> 24 32 </td></tr> 33 34 <tr><td colspan="3"> 35 <?php echo $form->input('Treasure.secret', array('size'=>15, 'maxlength'=>15, 'between'=>': ')); ?> 36 </td> 37 </tr> 38 25 39 <tr><td colspan="2"> 26 40 <?php -
trunk/app/views/treasures/view.ctp
r253 r441 1 <h2><?php echo $blog['User']['username']; ?>'s Treasures</h2> 1 <?php 2 //die(debug($data)); 2 3 3 <?php 4 echo '<div class="eport">'; 5 echo '<div class="port_title">' . $data['Treasure']['title'] . '</div>'; 6 echo '<div class="port_body">' . $data['Treasure']['instructions'] . '</div>'; 7 echo '<div class="port_created"> Created: ' . $data['Treasure']['created'] . '</div>'; 8 echo '</div>'; 4 $auth = false; 5 6 if ( $session->check('vclassrooms') ): 7 foreach($data['Vclassroom'] as $v): 8 if ( in_array($v['id'], $session->read('vclassrooms'))): 9 $auth = true; 10 $vclassroom_id = $v['id']; 11 break; 12 endif; 13 endforeach; 14 endif; 15 16 if ( $auth === true ): 17 echo $html->para(null, 'hi! '.$cU['User']['username'], array('style'=>'font-weight:bold;font-size:12pt;')); 18 echo $html->div('title', $blog['User']['username'] .'s Treasure Hunt'); 19 20 21 echo '<h1>'. $data['Treasure']['title'] . '</h1>'; 22 echo $html->div(null, '<b>Points:</b> '.$data['Treasure']['points']); 23 echo $html->div(null, $data['Treasure']['instructions']); 24 25 // ajax beggins 26 echo $ajax->div('loading',array('style'=>'display:none')).$html->image("static/loading.gif",array("alt"=>"Loading")).$ajax->divEnd('loading'); 27 28 echo $ajax->form(); 29 30 echo $form->hidden('ResultTreasure.vclassroom_id', array('value'=>$vclassroom_id) ); 31 echo $form->hidden('ResultTreasure.treasure_id', array('value'=>$data['Treasure']['id'])); 32 echo $form->hidden('ResultTreasure.points', array('value'=>$data['Treasure']['points'])); 33 echo $form->input('ResultTreasure.secret', array('size' => 15, 'maxlength'=>15, 'title'=>'Secret code', 'between'=>': ')); 34 echo $ajax->submit('Send secret word '.$cU['User']['username'], array("url" => "/treasures/chksw/", 35 "update"=>"updater", 36 "loading" => "Element.show('loading');Element.hide('updater')", 37 "complete" => "Element.hide('loading');Effect.Appear('updater')" 38 )); 39 40 // empty ajax div 41 echo $ajax->div('updater') . $ajax->divEnd('updater'); 42 // ajax ends 43 44 else: 45 echo $html->para(null, 'You must be logged in and belong to this class to see this page'); 46 endif; 47 9 48 ?> 49 50 <script type="text/javascript"> 51 52 function chkTest() 53 { 54 55 var answer = confirm("Are you sure?") 56 57 if (answer) 58 return true 59 else 60 return false 61 62 return true; 63 } 64 </script> -
trunk/app/views/users/admin_edit.ctp
r342 r441 1 1 <?php 2 //die( var_dump( $this->data ) ); 2 3 3 4 echo $javascript->link('myfunctions'); 4 5 5 //die( var_dump( $this->data ) );6 6 if ($this->data["User"]["id"] != $cU['User']['id']) 7 7 { … … 39 39 endif; 40 40 41 echo $form->input('User.website', array("size"=>35, "maxlength"=>50));42 43 41 echo $form->label('User.layout', 'Layout:' ); 44 45 42 $designs = array('rubyx'=>'Rubyx', 'school'=>'School', 'paris'=>'Paris'); 46 echo $form->select('User.layout', $designs, null, null, null, false,false);43 echo $form->select('User.layout', $designs, null, null, false); 47 44 48 45 echo $form->label('User.cv', 'Profile:' ); 49 echo $form->textarea('User.cv', array("cols" => 45, "rows" => 5)); 50 echo $form->error('User.cv', 'CV is required.'); 46 echo $form->textarea('User.cv', array("cols" => 70, "rows" => 7)); 51 47 52 echo $form->input('User.quote', array("size" => 40, "maxlength" => 150)); 53 echo $form->error('User.quote', 'A name is required.'); 48 echo $form->input('User.quote', array("size" => 70, "maxlength" => 150)); 54 49 55 50 echo $form->input('User.name_blog', array("size" => 45, "maxlength" => 150)); 56 echo $form->error('User.name_blog', 'A name_blog is required.'); 57 51 58 52 echo $form->label('User.newsletter', 'Subscribe to newsletter:' ); 59 53 echo $form->checkbox('User.newsletter', array("value" => 1)); 60 54 61 echo '</fieldset>';62 55 echo $form->end('Save'); 63 56 ?> 64 57 </fieldset> 65 58 </div> 66 59 -
trunk/app/views/vclassrooms/show.ctp
r419 r441 50 50 } 51 51 } 52 53 if ( count($data['Treasure']) > 0) 54 { 55 echo $html->div('titentry', 'Treasure Hunts'); 56 57 foreach($data['Treasure'] as $t) 58 { 59 echo $html->para(null, $html->link($t['title'], '/treasures/view/'.$t['id'])); 60 } 61 } 52 62 } 53 63
