diff --git a/src/classes/wishthis/User.php b/src/classes/wishthis/User.php index 8e5416f8..f39aeacb 100644 --- a/src/classes/wishthis/User.php +++ b/src/classes/wishthis/User.php @@ -41,7 +41,8 @@ class User return sha1($plainPassword); } - public static function getCurrent(): self { + public static function getCurrent(): self + { if (!isset($_SESSION['user'])) { $_SESSION['user'] = new self(); } @@ -250,7 +251,6 @@ class User /** * Returns a list of the users wishlists. - * Defaults to the currently logged in user. * * @return array */ @@ -315,7 +315,8 @@ class User * * @return bool Whether the log in was successful. */ - public function logIn(string $email = '', string $password = '', bool $user_login_is_persistent = false): bool { + public function logIn(string $email = '', string $password = '', bool $user_login_is_persistent = false): bool + { global $database; $login_was_successful = false; @@ -388,7 +389,7 @@ class User $sessionLifetime = 2592000 * 4; // 4 Months $sessionExpires = time() + $sessionLifetime; $sessionIsDev = defined('ENV_IS_DEV') && ENV_IS_DEV || '127.0.0.1' === $_SERVER['REMOTE_ADDR']; - $sessionOptions = array ( + $sessionOptions = array( 'domain' => getCookieDomain(), 'expires' => $sessionExpires, 'httponly' => true, @@ -457,19 +458,23 @@ class User ); } - public function getId(): int { + public function getId(): int + { return $this->id; } - public function getEmail(): string { + public function getEmail(): string + { return $this->email; } - public function getPassword(): string { + public function getPassword(): string + { return $this->password; } - public function getPower(): int { + public function getPower(): int + { return $this->power; } } diff --git a/src/classes/wishthis/Wishlist.php b/src/classes/wishthis/Wishlist.php index a5524764..cb85c307 100644 --- a/src/classes/wishthis/Wishlist.php +++ b/src/classes/wishthis/Wishlist.php @@ -46,54 +46,19 @@ class Wishlist * * @var int */ - private int $notification_send; + private int $notification_sent; public array $wishes = array(); public bool $exists = false; - public function __construct(int|string $id_or_hash) + public function __construct(array $wishlist_data) { - global $database; - - $column; - - if (is_numeric($id_or_hash)) { - $column = 'id'; - } elseif (is_string($id_or_hash)) { - $column = 'hash'; - } - - /** - * Get Wishlist - */ - $columns = $database - ->query( - 'SELECT * - FROM `wishlists` - WHERE `' . $column . '` = :id_or_hash;', - array( - 'id_or_hash' => $id_or_hash, - ) - ) - ->fetch(); - - if ($columns) { - $this->exists = true; - - $this->id = $columns['id']; - $this->user = $columns['user']; - $this->name = html_entity_decode($columns['name']); - $this->hash = $columns['hash']; - $this->notification_send = $columns['notification_send']; - } else { - return; - } - - /** - * Get Wishes - */ - // $this->wishes = $this->getWishes(); + $this->id = $wishlist_data['id']; + $this->user = $wishlist_data['user']; + $this->name = $wishlist_data['name']; + $this->hash = $wishlist_data['hash']; + $this->notification_sent = $wishlist_data['notification_sent'] ?? 0; } public function getWishes(array $options = array('placeholders' => array())): array @@ -233,4 +198,29 @@ class Wishlist return $title; } + + public function getId(): int + { + return $this->id; + } + + public function getUserId(): int + { + return $this->user; + } + + public function getName(): string + { + return $this->name; + } + + public function getHash(): string + { + return $this->hash; + } + + public function getNotificationSent(): int + { + return $this->notification_sent; + } } diff --git a/src/pages/parts/wishlist.php b/src/pages/parts/wishlist.php index 67f8f60c..6f988ea0 100644 --- a/src/pages/parts/wishlist.php +++ b/src/pages/parts/wishlist.php @@ -75,8 +75,8 @@ $user = User::getCurrent(); -id)) { ?> -
+ +