Changeset 747 for trunk/app/controllers
- Timestamp:
- 09/01/08 22:38:27 (3 months ago)
- Files:
-
- 1 modified
-
trunk/app/controllers/treasures_controller.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/treasures_controller.php
r728 r747 30 30 public function chksw() 31 31 { 32 $this->layout = 'ajax'; 33 34 if ( !empty($this->data['ResultTreasure']) ): 35 $this->Sanitize = new Sanitize; 36 37 $this->Sanitize->clean($this->data['ResultTreasure']); 38 39 $secret = $this->Treasure->field('secret', array('status'=>1,'id'=>$this->data['ResultTreasure']['treasure_id'])); 32 $this->layout = 'ajax'; 33 34 if ( !empty($this->data['ResultTreasure']) ): 35 $this->Sanitize = new Sanitize; 36 $this->Sanitize->clean($this->data['ResultTreasure']); 37 $conditions = array('ResultTreasure.treasure_id'=>$this->data['ResultTreasure']['treasure_id'],'ResultTreasure.user_id'=>$this->Auth->user('id')); 38 $answer = $this->Treasure->ResultTreasure->field('id', $conditions); 39 40 if ($answer != false): 41 $this->set('msg', __('You already answered this Scavenger Hunt', true)); 42 $this->render('chksw', 'ajax'); 43 return false; 44 endif; 45 46 $secret = $this->Treasure->field('secret', array('status'=>1,'id'=>$this->data['ResultTreasure']['treasure_id'])); 40 47 41 if ( $this->data['ResultTreasure']['secret'] == $secret ):48 if ( $this->data['ResultTreasure']['secret'] == $secret ): 42 49 $this->data['ResultTreasure']['user_id'] = $this->Auth->user('id'); 43 44 50 $this->Treasure->ResultTreasure->save($this->data['ResultTreasure']); 45 46 51 $this->set('msg', 'Cool!, the '. $this->data['ResultTreasure']['points'] .' points are yours'); 47 52 $this->render('chksw', 'ajax'); 48 53 49 else:50 $this->set('msg', 'Sorry, word is incorrect');51 $this->render('chksw', 'ajax');52 endif;54 else: 55 $this->set('msg', __('Sorry, code is incorrect', true)); 56 $this->render('chksw', 'ajax'); 57 endif; 53 58 endif; 54 59 }
