Exemple #1
0
    /**
     * 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;
    }
<?php

/**
 * Get the crafting for the given id.
 *
 * @package ajax
 * @author  friend8 <*****@*****.**>
 * @license https://www.gnu.org/licenses/lgpl.html LGPLv3
 */
require_once __DIR__ . '/../lib/system/config.default.php';
require_once __DIR__ . '/../lib/system/util/mysql.php';
$crafting = \Model\Crafting::loadById($_POST['id']);
echo json_encode($crafting->getAsArray());
Exemple #3
0
 /**
  * Remove a crafting.
  *
  * @param \Model\Crafting $crafting
  *
  * @return void
  */
 protected function removeCrafting($crafting)
 {
     $crafting->remove();
     redirect('index.php?page=Craftings');
 }
<?php

/**
 * Add talent points for crafting an item.
 *
 * @package ajax
 * @author  friend8 <*****@*****.**>
 * @license https://www.gnu.org/licenses/lgpl.html LGPLv3
 */
require_once __DIR__ . '/../lib/system/config.default.php';
require_once __DIR__ . '/../lib/system/util/mysql.php';
session_start();
$crafting = \Model\Crafting::loadById($_POST['data']['craftingId']);
$crafting->addTalentPoints($_POST['data']['talentPoints']);
echo json_encode(array('ok' => true));
<?php

/**
 * Add a crafting for an existing blueprint.
 *
 * @package ajax
 * @author  friend8 <*****@*****.**>
 * @license https://www.gnu.org/licenses/lgpl.html LGPLv3
 */
require_once __DIR__ . '/../lib/system/config.default.php';
require_once __DIR__ . '/../lib/system/util/mysql.php';
session_start();
$response = \Model\Crafting::create(array_merge(array('userId' => $_SESSION['userId']), $_POST['data']));
echo json_encode(array('ok' => $response));