function setNetwork(Network $network) { $net = $this->mDb->escapeString($network->getId()); $this->mDb->execSqlUpdate("UPDATE nodes SET network_id = '{$net}' WHERE node_id = '{$this->getId()}'"); $this->refresh(); }
/** Create a new User in the database * @param $id The id to be given to the new user * @return the newly created User object, or null if there was an error */ static function createUser($id, $username, Network $account_origin, $email, $password) { $db = AbstractDb::getObject(); $object = null; $id_str = $db->escapeString($id); $username_str = $db->escapeString($username); $account_origin_str = $db->escapeString($account_origin->getId()); $email_str = $db->escapeString($email); $password_hash = $db->escapeString(User::passwordHash($password)); $status = ACCOUNT_STATUS_VALIDATION; $token = User::generateToken(); $db->execSqlUpdate("INSERT INTO users (user_id,username, account_origin,email,pass,account_status,validation_token,reg_date) VALUES ('{$id_str}','{$username_str}','{$account_origin_str}','{$email_str}','{$password_hash}','{$status}','{$token}',CURRENT_TIMESTAMP)"); $object = self::getObject($id); return $object; }
/** * Set this vhost's default network * * @return bool True on success, false on failure */ public function &setDefaultNetwork(Network $network) { $db = AbstractDb::getObject(); // Init values $retVal = true; if ($network != $this->getDefaultNetwork()) { $value = $db->escapeString($network->getId()); $retVal = $db->execSqlUpdate("UPDATE virtual_hosts SET default_network = '{$value}' WHERE virtual_host_id = '{$this->getId()}'", false); $this->refresh(); } return $retVal; }