public function create(User $_poster, \string $text, \int $who_for = self::WF_ACTIVES) { $query = "INSERT INTO announcement (poster_id, `text`, date_posted, who_for) VALUES (:p, :t, :d, :w)"; $this->_poster = $_poster; $this->_pdo->perform($query, ["p" => $this->poster_id = $_poster->getId(), "t" => $this->text = $text, "d" => $this->date_posted = Utility::getDateTimeForMySQLDateTime(), "w" => $this->who_for = $who_for]); $this->id = $this->_pdo->lastInsertId(); }
public function create(User $_user) { $this->_user = $_user; $query = "INSERT INTO remember (user_id, token, date_expires, user_agent) VALUES (:u, :t, :d, :a)"; $this->_pdo->perform($query, ["u" => $this->user_id = $_user->getId(), "t" => $this->token = Utility::getRandomString(30), "d" => $this->date_expires = Utility::getExpiryAsMySQLDateTime(self::EXPIRE_TIME), "a" => $this->user_agent = $_SERVER["HTTP_USER_AGENT"]]); $cookie_val = $_user->getEmailUniversity() . self::$COOKIE_SEPARATOR . $this->token; setcookie(self::$COOKIE_REMEMBER, $cookie_val, time() + Utility::SECONDS_IN_DAY * 30, "/"); $this->id = $this->_pdo->lastInsertId(); }
public function create(User $_user, string $extension, string $mime_type, string $original_name, string $temp_location, bool $is_image) { $query = "INSERT INTO `file` (user_id, extension, mime_type, md5, original_name, date_added, is_image)\n\t\t\t\t\t VALUES (:u, :e, :mt, :m, :o, :d, :i)"; $this->_pdo->perform($query, ["u" => $this->user_id = $_user->getId(), "e" => $this->extension = $extension, "mt" => $this->mime_type = $mime_type, "m" => $this->md5 = md5_file($temp_location), "o" => $this->original_name = $original_name, "d" => $this->date_added = Utility::getDateTimeForMySQLDateTime(), "i" => $this->is_image = $is_image]); $stream = fopen($temp_location, "r+"); if (!$this->_filesystem->has($this->getDirMain())) { $this->_filesystem->createDir($this->getDirMain()); } if (!$this->_filesystem->has($this->getDirSub())) { $this->_filesystem->createDir($this->getDirSub()); } $this->_filesystem->writeStream($this->getPath(), $stream, ["visibility" => AdapterInterface::VISIBILITY_PUBLIC]); fclose($stream); }
public function getEmailHtml(\string $template_name, User $to_user, \string $view_key) : \string { $base_path = __DIR__ . self::$FOLDER_PATH . DIRECTORY_SEPARATOR . $template_name . DIRECTORY_SEPARATOR; $body_html = file_get_contents($base_path . self::$HTML_FILE_NAME); $query = "SELECT * FROM email_log WHERE view_key = :v AND template = :t AND user_id = :u"; $data = $this->_pdo->fetchOne($query, ["v" => $view_key, "t" => $template_name, "u" => $to_user->getId()]); if (!$data) { return ""; } $data = unserialize($data["vars"]); foreach ($data as $key => $var) { $body_html = str_replace("#!" . $key . "!#", $var, $body_html); } return str_replace("#!BASE_URL!#", Config::getBaseUrl(), $body_html); }
public function queueResizeProfileImage(User $_user) { $this->send(self::A_RESIZE_PROFILE_IMAGE, ["user_id" => $_user->getId()]); }
/** * @param BasePDO $_pdo * @param User $_user * @return self[] */ public static function findAllForUser(BasePDO $_pdo, User $_user) : array { return $_pdo->fetchAssoc("SELECT * FROM fee WHERE user_id = :u", ["u" => $_user->getId()], function ($row) use($_pdo) { return new self($_pdo, $row); }); }
public function update(string $name, string $notes, bool $all_day_event, DateTime $start, DateTime $end, User $_lmod_user, int $repeat_type, int $n_times) { $this->_lmod_user = $_lmod_user; $query = "UPDATE event_group SET `start` = :s, `end` = :e, all_day_event = :a, `name` = :m, notes = :n,\n\t\t\t\t\t repeat_type = :r, n_times = :t, lmod_date = :u, lmod_user_id = :l\n\t\t\t\t\t WHERE id = :i"; $this->_pdo->perform($query, ["s" => $this->start = $start, "e" => $this->end = $end, "a" => $this->all_day_event = $all_day_event, "m" => $this->name = $name, "n" => $this->notes = $notes, "r" => $this->repeat_type = $repeat_type, "t" => $this->n_times = $n_times, "u" => $this->lmod_user_id = $_lmod_user->getId(), "l" => $this->lmod_date = Utility::getDateTimeForMySQLDateTime(), "i" => $this->id]); }
public function update(string $name, string $notes, bool $all_day_event, DateTime $start, DateTime $end, User $_lmod_user) { $this->_lmod_user = $_lmod_user; $query = "UPDATE `event` SET `start` = :s, `end` = :e, all_day_event = :a, `name` = :m, notes = :n,\n\t\t\t\t\t lmod_user_id = :u, lmod_date = :l WHERE id = :i"; $this->_pdo->perform($query, ["m" => $this->name = $name, "n" => $this->notes = $notes, "a" => $this->all_day_event = $all_day_event, "s" => $this->start = Utility::getDateTimeForMySQLDateTime($start), "e" => $this->end = Utility::getDateTimeForMySQLDateTime($end), "u" => $this->lmod_user_id = $_lmod_user->getId(), "l" => $this->lmod_date = Utility::getDateTimeForMySQLDateTime(), "i" => $this->id]); }
public function queueUserPasswordResetEmail(User $_user) { $this->send(self::A_USER_PASSWORD_RESET_EMAIL, ["user_id" => $_user->getId()]); }
/** * @param BasePDO $_pdo * @param User $_user * @return Swag[] */ public static function findAllByCreator(BasePDO $_pdo, User $_user) : array { return $_pdo->fetchAssoc("SELECT * FROM swag WHERE creator_id = :uid", ["uid" => $_user->getId()], function (array $row) use($_pdo) { return new self($_pdo, $row); }); }