Changeset 747 for trunk/app/controllers

Show
Ignore:
Timestamp:
09/01/08 22:38:27 (3 months ago)
Author:
aarkerio
Message:

Little Bugs fixed

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/controllers/treasures_controller.php

    r728 r747  
    3030 public function chksw() 
    3131 { 
    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'])); 
    4047                  
    41       if ( $this->data['ResultTreasure']['secret'] ==  $secret ): 
     48    if ( $this->data['ResultTreasure']['secret'] ==  $secret ): 
    4249        $this->data['ResultTreasure']['user_id'] = $this->Auth->user('id'); 
    43        
    4450    $this->Treasure->ResultTreasure->save($this->data['ResultTreasure']); 
    45  
    4651        $this->set('msg', 'Cool!, the '. $this->data['ResultTreasure']['points'] .' points are yours'); 
    4752        $this->render('chksw', 'ajax'); 
    4853      
    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;  
    5358   endif; 
    5459 }