public function saveNew() { $this->secret = $this->generateSecret(); $this->date = date('Y-m-d H:i:s'); $this->official = 0; $this->status = 0; if (empty($this->url)) { $this->url = ''; } return parent::saveNew(); }
public function saveNew() { $this->id = ''; $user = new User(); $user = $user->get($this->uid); if (!$user) { throw new Exception('user not found'); } $this->country = $user->country; $id = parent::saveNew(); return $id; }
public function saveNew() { $this->id = ''; $this->quality = 1; $this->pendingUnits = 0; $this->money = 0; $this->maxEmployees = self::MIN_EMPLOYEES; $user = new User(); $user = $user->get($this->uid); if (!$user) { throw new Exception('user not found'); } if ($user->gold < self::CREATION_COST) { throw new Exception('no gold enough'); } $id = parent::saveNew(); if ($id) { $user->gold -= self::CREATION_COST; $user->save(); } return $id; }
/** * creates a new user * * @return mixed (uid or false) */ public function saveNew() { $this->status = self::STATUS_PENDING; $this->gold = 0; $this->xp = 0; $this->language = 'en'; $q = "select `id` from `" . $this->table . "` where `email`='" . $this->email . "' OR `nick`='" . $this->nick . "' LIMIT 1"; $rows = Service::getDB()->query($q); if (sizeof($rows) > 0) { return false; } return parent::saveNew(); }