예제 #1
0
 /**
  * Process uploaded files and removing of characters, as well as showing of the characters list.
  *
  * @return void
  */
 public function process()
 {
     if ($_FILES['fileupload']) {
         $file = $_FILES['fileupload']['tmp_name'];
         $heroImport = new \Helper\HeroImport(file_get_contents($file));
         if ($heroImport->import()) {
             redirect('index.php?page=Characters&success=1');
         } else {
             redirect('index.php?page=Characters&error=1');
         }
     }
     if ($_GET['remove']) {
         $this->removeCharacter(\Model\Character::loadById($_GET['remove']));
     }
     $this->getTemplate()->assign('characters', \Listing\Characters::loadList());
 }
예제 #2
0
    /**
     * 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;
    }
예제 #3
0
 /**
  * Fill the data from the array into the object and cast them to the nearest possible type.
  *
  * @param array $data
  *
  * @return void
  */
 public function fill($data)
 {
     foreach ($data as $key => $value) {
         if ($key === 'blueprintId') {
             $this->blueprint = \Model\Blueprint::loadById($value);
         } elseif ($key === 'characterId') {
             $this->character = \Model\Character::loadById($value);
         } elseif ($key === 'done') {
             $this->{$key} = (bool) $value;
         } elseif (property_exists($this, $key)) {
             $this->{$key} = $this->castToType($value);
         }
     }
 }