Example #1
0
 function init()
 {
     parent::init();
     $this->defaultValue(false);
     $this->type('boolean');
     $this->owner->addCondition($this->short_name, false);
 }
Example #2
0
 public function init()
 {
     parent::init();
     if ($this->action == 'edit') {
         $this->addJS();
     }
 }
Example #3
0
 protected function init()
 {
     parent::init();
     $this->addValidator(function () {
         if ($this->multiple && array_diff($this->value, array_keys($this->values))) {
             return Lang::trans('SELECT_INVALID_VALUE');
         }
     });
 }
Example #4
0
 function init()
 {
     parent::init();
     if ($this->json) {
         $this->encode = function ($t) {
             return json_encode($t);
         };
         $this->decode = function ($t) {
             return json_decode($t, true);
         };
     }
 }
 public function getField($input)
 {
     global $Database;
     if (isset($input['x']) && isset($input['y'])) {
         $x = $input['x'];
         $y = $input['y'];
     } elseif (isset($input['col']) && isset($input['row'])) {
         $cols = explode(' ', 'a b c d e f g h i j k l m n o p q r s t u v w x y z');
         $x = array_search($input['col'], $cols);
         $y = $input['row'] - 1;
     }
     $id = $Database->getID('fields', array('board_id' => $this->id, 'x' => $x, 'y' => $y));
     $Field = new Field();
     $Field->id = $id;
     $Field->init();
     return $Field;
 }
Example #6
0
 /**
  *	Surcharge de l'initialisation
  *
  */
 public function init()
 {
     parent::init();
     $this->joinid = $this->value['id'];
     $this->joinfieldvalue = $this->value[$this->fieldtoshow];
 }
Example #7
0
File: Field.php Project: atk4/atk4
 public function init()
 {
     parent::init();
     $this->type('reference_id');
 }
Example #8
0
 public function init()
 {
     parent::init();
     $this->editable(false);
 }
 function playword($params)
 {
     global $Database;
     // Check parameter count
     if (count($params) < 4) {
         die('Wrong parameter count!');
     }
     // Check if user is logged in
     if (!$this->Auth->isLoggedIn()) {
         $this->redirect(array('controller' => 'users', 'action' => 'login'));
     }
     // check game
     $Game = new Game();
     $Game->id = trim($params[0]);
     $Game->init();
     if (!empty($Game->data)) {
         if ($Game->ActiveUser->id != $this->Auth->User->id) {
             $this->redirect(array('controller' => 'games', 'action' => 'view', 'params' => array($Game->id)));
         }
     }
     // check field
     $Field = new Field();
     $Field->id = trim($params[1]);
     $Field->init();
     if (!empty($Field->data)) {
         if ($Field->data['board_id'] != $Game->Board->id) {
             $this->redirect(array('controller' => 'games', 'action' => 'view', 'params' => array($Game->id)));
         }
     }
     // check direction
     $direction = substr($params[3], 0, 1);
     if ($direction == 'f') {
         $direction = 'h';
     }
     // 'false': *one letter*
     if (!in_array($direction, array('h', 'v'))) {
         die('Incorrect direction: ' . $direction);
     }
     // check word for empty
     $word = $params[2];
     $letters = str_split($word);
     if (empty($letters)) {
         $this->redirect(array('controller' => 'games', 'action' => 'view', 'params' => array($Game->id)));
     }
     // get rack tiles
     $rack_tiles = $Database->fetchObjects('Tile', "\r\n\t\t\tSELECT `tile_id` FROM `rack_tiles`\r\n\t\t\tWHERE `game_id` = {$Game->id}\r\n\t\t\t  AND `user_id` = {$this->Auth->User->id}\r\n\t\t");
     // the real, letter by letter, check
     $to_update = array();
     foreach ($letters as $i => $letter) {
         // get x and y for this letter
         $x = $Field->data['x'];
         $y = $Field->data['y'];
         if ($direction == 'h') {
             $x += $i;
         } elseif ($direction == 'v') {
             $y += $i;
         }
         // check if field exists
         $field_id = $Database->getID('fields', array('board_id' => $Game->Board->id, 'x' => $x, 'y' => $y));
         // check if word fits in board
         if (!$field_id) {
             die('Field does not exist!');
         }
         // (double) check if field exists
         $TheField = new Field();
         $TheField->id = $field_id;
         $TheField->init();
         if (empty($TheField->data)) {
             die('Field does not exist! o3qaigksd');
         }
         // check if field is free, if not, if the letter is the specified letter
         $placed_tile_id = $Database->getID('placed_tiles', array('game_id' => $Game->Board->id, 'field_id' => $TheField->id));
         if ($placed_tile_id) {
             $rows = $Database->fetchObjects('Tile', "\r\n\t\t\t\t\tSELECT `tile_id` AS `id` FROM `placed_tiles` WHERE `id` = {$placed_tile_id}\r\n\t\t\t\t");
             $Tile = $rows[0];
             if (strtoupper($Tile->data['letter']) != strtoupper($letter)) {
                 die('Field at (' . $x . ', ' . $y . ') already used, and other letter than specified!');
             }
             // everything's okay for this letter! ..DO NOT put it in the to_update array,
             // because letter is already played!
         } else {
             // check if letter is in rack, and if: what is it's tile id?
             $TheTile = false;
             foreach ($rack_tiles as $key => $Tile) {
                 if (strtoupper($Tile->data['letter']) == strtoupper($letter)) {
                     $TheTile = $Tile;
                     unset($rack_tiles[$key]);
                     break;
                     // let's not use tiles twice.. ;)
                 }
             }
             if (!$TheTile) {
                 die('You do not have the letter ' . strtoupper($letter) . '!');
             }
             // everything's okay for this letter! ..put it in the to_update array (hooray)!
             $to_update[] = "\r\n\t\t\t\t\tDELETE FROM `rack_tiles`\r\n\t\t\t\t\tWHERE `game_id` = {$Game->id}\r\n\t\t\t\t\t  AND `user_id` = {$this->Auth->User->id}\r\n\t\t\t\t\t  AND `tile_id` = {$TheTile->id}\r\n\t\t\t\t\tLIMIT 1\r\n\t\t\t\t";
             $to_update[] = "\r\n\t\t\t\t\tINSERT INTO `placed_tiles` (`game_id`, `tile_id`, `field_id`) VALUES\r\n\t\t\t\t\t({$Game->id}, {$TheTile->id}, {$TheField->id});\r\n\t\t\t\t";
         }
     }
     // wow, did we really survive all the checks?! celebrate!
     foreach ($to_update as $sql) {
         $result = mysql_query($sql) or die('3a;lihgalskgasdh - ' . $sql . ' - ' . mysql_error());
     }
     // switch active/inactive -ness
     $sql = "\r\n\t\t\tUPDATE `games` SET\r\n\t\t\t\t`active_user_id`   = {$Game->data['inactive_user_id']},\r\n\t\t\t\t`inactive_user_id` = {$Game->data['active_user_id']}\r\n\t\t\tWHERE `id` = {$Game->id};\r\n\t\t";
     //$result = mysql_query($sql) or die('akergsjhdguiyg '.mysql_error()); !TODO: uncomment this line
     // ..sit back and enjoy a well-deserved rest! grab a cold beer, go out for some sunshine, play a relaxing game of scrabble, ..?
     $this->redirect(array('controller' => 'games', 'action' => 'view', 'params' => array($Game->id)));
 }
Example #10
0
<?php

namespace ATPContact\Model;

class Field extends \ATP\ActiveRecord
{
    public function displayName()
    {
        return $this->label;
    }
}
Field::init();