Exemplo n.º 1
0
 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();
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 4
0
 /**
  * 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();
 }