Exemple #1
0
 public function __construct($fen = null)
 {
     if (!isset($fen)) {
         $fen = ChessRegistry::getDefaultFen();
     }
     $this->fen = $this->getValidFen($fen);
     parent::__construct();
 }
Exemple #2
0
 protected function populate()
 {
     parent::populate();
     if (!$this->getId() && !is_numeric($this->arguments[0])) {
         $this->setFen($this->arguments[0]);
         $this->commit();
     }
 }
 public function populate()
 {
     parent::populate();
     if (!$this->getId()) {
         $this->setMetadataKey($this->arguments[0]);
         $this->commit();
     }
 }
Exemple #4
0
 protected function populate()
 {
     parent::populate();
     if (!$this->getId()) {
         $this->setPlayerId($this->arguments[0]);
         $this->setCategory($this->arguments[1]);
         $this->commit();
     }
 }
 public function __construct($id = null)
 {
     if (!isset(self::$tempPath)) {
         self::$tempPath = LudoDBRegistry::get(self::FILE_UPLOAD_KEY);
         if (!isset(self::$tempPath)) {
             throw new Exception("Temp path for file uploads not set. Use LudoDBRegistry::set(self::FILE_UPLOAD_KEY, 'your/path'); to set path", 500);
         }
     }
     parent::__construct($id);
 }
 /**
  * Creates new LudoDBCache instance. An empty LudoDBService class is sent to the constructor along
  * with constructor arguments. The cache class will search for records where "class_name" equals
  * class of given service and arguments compiled to a key matches cache_key in the database table.
  * @param LudoDBService $resource
  * @param array $arguments
  */
 public function __construct(LudoDBService $resource = null, array $arguments = null)
 {
     if (isset($resource)) {
         $resourceName = get_class($resource);
         $cacheKey = $this->getCacheKey($resourceName, $arguments);
         parent::__construct($cacheKey);
         if (isset($cacheKey)) {
             $this->setKey($cacheKey);
             $this->setClassName($resourceName);
             $this->JSON = $this->getValue('cache_value');
         }
     } else {
         parent::__construct();
     }
 }
Exemple #7
0
 public function save($data)
 {
     $ret = parent::save($data);
     if (isset($data['author'])) {
         $id = $this->getId();
         $authors = explode(";", $data['author']);
         foreach ($authors as $author) {
             $a = new Author();
             $a->setName($author);
             $a->commit();
             $bookAuthor = new BookAuthor();
             $bookAuthor->setBookId($id);
             $bookAuthor->setAuthorId($a->getId());
             $bookAuthor->commit();
         }
     }
     return $ret;
 }
 /**
  * Validate data for "update" statement
  * @param LudoDBModel $model
  */
 public function validateUpdate($model)
 {
     $data = $model->getUncommitted();
     $validationDef = $model->configParser()->getColumnsToValidate();
     if (empty($validationDef)) {
         return;
     }
     foreach ($validationDef as $column => $def) {
         if (isset($data[$column])) {
             $this->validateColumn($column, $data[$column], $def);
         }
     }
 }
Exemple #9
0
 public function clearCache()
 {
     LudoDBCache::clearByClass('Capitals');
     parent::clearCache();
 }
 /**
  * Get tables referenced by a model, i.e. foreign keys.
  * @param LudoDBModel $model
  * @return array
  */
 private function getReferencedTables(LudoDBModel $model)
 {
     $ret = array();
     $references = $model->configParser()->getTableReferences();
     foreach ($references as $reference) {
         $ret[] = $reference['table'];
     }
     return $ret;
 }
Exemple #11
0
 public function __construct($key = null)
 {
     parent::__construct($key);
 }
 /**
  * Return values for a row using LudoDBModel as a parser/filter.
  * @param LudoDBModel $model
  * @param array $columns
  * @return array
  */
 protected function getValuesFromModel($model, $columns)
 {
     return $model->getSomeValues($columns);
 }
Exemple #13
0
 public function edit($data)
 {
     $cp = CurrentPlayer::getInstance();
     if (!$cp->hasAccessTo(ChessRoles::EDIT_USERS) && $cp->getId() !== $this->getId()) {
         throw new LudoDBUnauthorizedException("You are not allowed to edit this user");
     }
     if (!$cp->hasAccessTo(ChessRoles::EDIT_USERS)) {
         if (isset($data['user_access'])) {
             unset($data['user_access']);
         }
     }
     if (isset($values['password']) && !$values['password']) {
         unset($values['password']);
     }
     return parent::save($data);
 }
 public function read()
 {
     $ret = parent::read();
     $ret['percent'] = round($ret['current'] / $ret['steps'] * 100);
     return $ret;
 }
 public function sqlHandler()
 {
     return parent::sqlHandler();
 }
Exemple #16
0
 public function save($data)
 {
     $data = $this->withSpecialMetadataKeysMoved($data);
     if (isset($data['white'])) {
         $data['white_id'] = $this->getPlayerIdByName($data['white']);
     }
     if (isset($data['black'])) {
         $data['black_id'] = $this->getPlayerIdByName($data['black']);
     }
     return parent::save($data);
 }