/** * Create a new material type from the given array. * array( * 'name' => 'test', * ) * * @param array $data * * @return boolean */ public static function create($data) { if (!$data['name']) { return false; } $sql = ' INSERT INTO materialTypes SET name = ' . \sqlval(trim($data['name'])) . ' '; $id = query($sql); return array('id' => $id, 'name' => trim($data['name'])); }
/** * Load all characters for the logged in user. * * @return \self */ public static function loadList() { $sql = ' SELECT `characterId` FROM characters WHERE userid = ' . \sqlval($_SESSION['userId']) . ' AND !deleted '; $characterIds = query($sql, true); $obj = new self(); if (empty($characterIds)) { return $obj; } $list = array(); foreach ($characterIds as $character) { $list[$character['characterId']] = \Model\Character::loadById($character['characterId']); } $obj->setList($list); return $obj; }
/** * Load all assets for the given material. * * @param integer $materialId * * @return \self */ public static function loadListMaterial($materialId) { $sql = ' SELECT `materialAssetId` FROM materialAssets WHERE `materialId` = ' . \sqlval($materialId) . ' AND !deleted ORDER BY percentage '; $materialAssetIds = query($sql, true); $obj = new self(); if (empty($materialAssetIds)) { return $obj; } $list = array(); foreach ($materialAssetIds as $materialAsset) { $list[$materialAsset['materialAssetId']] = \Model\MaterialAsset::loadById($materialAsset['materialAssetId']); } $obj->setList($list); return $obj; }
/** * Load all available blueprints for the logged in user. * * @return \self */ public static function loadList($orderBy = 'name') { $sql = ' SELECT `blueprintId` FROM blueprints WHERE userid = ' . \sqlval($_SESSION['userId']) . ' AND !deleted ORDER BY ' . sqlval($orderBy, false) . ' '; $blueprintIds = query($sql, true); $obj = new self(); if (empty($blueprintIds)) { return $obj; } $list = array(); foreach ($blueprintIds as $blueprint) { $list[$blueprint['blueprintId']] = \Model\Blueprint::loadById($blueprint['blueprintId']); } $obj->setList($list); return $obj; }
/** * Load all craftings for the logged in user. * * @param boolean $onlyUnfinished * * @return \self */ public static function loadList($onlyUnfinished = false) { $sql = ' SELECT `craftingId` FROM craftings WHERE `userId` = ' . \sqlval($_SESSION['userId']) . ' AND !deleted ' . ($onlyUnfinished ? 'AND !done' : '') . ' ORDER BY done, `name` '; $craftingIds = query($sql, true); $obj = new self(); if (empty($craftingIds)) { return $obj; } $list = array(); foreach ($craftingIds as $crafting) { $list[$crafting['craftingId']] = \Model\Crafting::loadById($crafting['craftingId']); } $obj->setList($list); return $obj; }
/** * Remove this technique. * * @return void */ public function remove() { $sql = ' UPDATE techniques SET deleted = 1 WHERE `techniqueId` = ' . \sqlval($this->techniqueId) . ' '; \query($sql); }
/** * Remove the material and its assets. * * @return void */ public function remove() { $sql = ' UPDATE materials, materialAssets SET materials.deleted = 1, materialAssets.deleted = 1 WHERE materials.`materialId` = ' . \sqlval($this->materialId) . ' AND materialAssets.`materialId` = materials.`materialId` '; \query($sql); }
/** * Remove the current character. * * @return void */ public function remove() { $sql = ' UPDATE characters SET deleted = 1 WHERE `characterId` = ' . sqlval($this->characterId) . ' '; query($sql); }
OR `key` = "retrievePassword" OR `key` = "emailAlreadyInUse" OR `key` = "lostPasswordSubject" OR `key` = "lostPasswordMessage" OR `key` = "emptyEmail" OR `key` = "lostPasswordNoUserFound" OR `key` = "lostPasswordMailSent" '); $results[] = query_raw(' ALTER TABLE `users` ADD COLUMN `salt` VARCHAR(255) NOT NULL COLLATE "utf8_bin" AFTER `password` '); $sql = ' SELECT `userId`, `password` FROM users '; $users = query($sql, true); foreach ($users as $user) { $passwordParts = explode('$', $user['password']); $sql = ' UPDATE users SET password = '******'3']) . ', salt = ' . sqlval($passwordParts['2']) . ' WHERE `userId` = ' . sqlval($user['userId']) . ' '; $results[] = !!query($sql); } return !in_array(false, $results); });
/** * Create a new material asset from the given array. * array( * 'percentage' => array( * 0 => 50, * 1 => 50, * ), * 'timeFactor' => array( * 0 => 1, * 1 => 1, * ), * 'priceFactor' => array( * 0 => 2, * 0 => 1.5, * ), * 'priceWeight' => array(), * 'currency' => array( * 0 => 'S', * 1 => 'D', * ), * 'proof' => array( * 0 => 0, * 1 => -1, * ), * 'breakFactor' => array( * 0 => 1, * 1 => -1, * ), * 'hitPoints' => array( * 0 => 0, * 1 => 1, * ), * 'armor' => array( * 0 => 0, * 1 => 0, * ), * 'weaponModificator' => array( * 0 => '0/0', * 1 => '-1/0', * ), * ) * * @param array $data * * @return boolean */ public static function create($data) { if (!$data['materialId'] && !$data['percentage'] && !$data['timeFactor'] && (!$data['priceFactor'] || $data['priceWeight'])) { return false; } $weaponModificators = array(); if (!empty($data['weaponModificator'])) { $weaponModificators = \Helper\WeaponModificator::getWeaponModificatorArray($data['weaponModificator']); } if (!empty($data['priceWeight'])) { $moneyHelper = new \Helper\Money(); $data['priceWeight'] = $moneyHelper->exchange($data['priceWeight'], $data['currency']); } $sql = ' INSERT INTO materialAssets SET materialId = ' . \sqlval($data['materialId']) . ', percentage = ' . \sqlval($data['percentage']) . ', timeFactor = ' . \sqlval($data['timeFactor']) . ', priceFactor = ' . \sqlval($data['priceFactor']) . ', priceWeight = ' . \sqlval($data['priceWeight']) . ', proof = ' . \sqlval($data['proof']) . ', breakFactor = ' . \sqlval($data['breakFactor']) . ', hitPoints = ' . \sqlval($data['hitPoints']) . ', armor = ' . \sqlval($data['armor']) . ', weaponModificator = ' . \sqlval(json_encode($weaponModificators)) . ' '; query($sql); return true; }
/** * Remove the blueprint. * * @return void */ public function remove() { $sql = ' UPDATE materialstoblueprints SET deleted = 1 WHERE `blueprintId` = ' . \sqlval($this->blueprintId) . ' '; \query($sql); $sql = ' UPDATE techniquestoblueprints SET deleted = 1 WHERE `blueprintId` = ' . \sqlval($this->blueprintId) . ' '; \query($sql); $sql = ' UPDATE blueprints SET deleted = 1 WHERE `blueprintId` = ' . \sqlval($this->blueprintId) . ' '; \query($sql); }
/** * Remove the item type. * * @return void */ public function remove() { $sql = ' UPDATE itemTypes SET deleted = 1 WHERE `itemTypeId` = ' . \sqlval($this->itemTypeId) . ' '; \query($sql); }
/** * Remove the crafting. * * @return void */ public function remove() { $sql = ' UPDATE craftings SET deleted = 1 WHERE `craftingId` = ' . \sqlval($this->craftingId) . ' '; \query($sql); }