Beispiel #1
0
 public function getCreator() : User
 {
     if (!$this->_creator) {
         $this->_creator = User::find($this->_pdo, $this->creator_id);
     }
     return $this->_creator;
 }
Beispiel #2
0
 public function getUser() : User
 {
     if (!$this->_user) {
         $this->_user = User::find($this->_pdo, $this->user_id);
     }
     return $this->_user;
 }
Beispiel #3
0
 public static function getDevUser(BasePDO $_pdo) : User
 {
     if (self::$DEV_USER) {
         return self::$DEV_USER;
     }
     self::readData();
     return self::$DEV_USER = User::findByEmail($_pdo, self::$DATA["dev_user_email"]);
 }
Beispiel #4
0
 private function resizeProfileImage(FilesystemInterface $_filesystem, \int $user_id)
 {
     $_user = User::find($this->_pdo, $user_id);
     $_file = $_user->getImageFile($_filesystem);
     $_img = GDImageManipulator::read($_file);
     $_img->resize(User::PROFILE_IMAGE_WIDTH, User::PROFILE_IMAGE_HEIGHT);
     $_file->write($_img->getStream($_file->getExtension()));
     unset($_user, $_file, $_img);
 }
 public function main()
 {
     $_user = User::findByVerificationToken($this->_pdo, $_GET["t"]);
     if (is_null($_user)) {
         $this->setError(self::$E_TOKEN_INVALID);
         return;
     }
     if ($_user->isTokenExpiredAccountVerify()) {
         $_user->reissueVerificationToken();
         $worker = new EmailWorker($this->_pdo);
         $worker->queueUserConfirmationEmail($_user);
         $this->setError(self::$E_TOKEN_EXPIRED);
         return;
     }
     $_user->verifyAccount();
 }
 public function main()
 {
     $org_id = Utility::cleanInt($_POST["org_id"], 1);
     $uni_id = Utility::cleanInt($_POST["uni_id"], 1);
     $email = Utility::cleanString($_POST["university_email"]);
     $name_first = Utility::cleanString($_POST["name_first"]);
     $name_last = Utility::cleanString($_POST["name_last"]);
     $password = Utility::cleanString($_POST["password"]);
     $pledge_class = Utility::cleanString($_POST["pledge_class"]);
     $year = Utility::getDateTimeFromYear(Utility::cleanString($_POST["year"]));
     if (!$org_id) {
         $this->setError(self::$E_ORG_INVALID);
         return;
     }
     if (!$uni_id) {
         $this->setError(self::$E_UNI_INVALID);
         return;
     }
     $_org = GreekOrganization::find($this->_pdo, $org_id);
     $_uni = University::find($this->_pdo, $uni_id);
     if (is_null($_org)) {
         $this->setError(self::$E_ORG_INVALID);
         return;
     }
     if (is_null($_uni)) {
         $this->setError(self::$E_UNI_INVALID);
         return;
     }
     if (Chapter::findByOrgAndUni($this->_pdo, $_org, $_uni)) {
         $this->setError(self::$E_CHAPTER_EXISTS);
         return;
     }
     if ($name_first == "") {
         $this->setError(self::$E_NAME_F_INVALID);
         return;
     }
     if ($name_last == "") {
         $this->setError(self::$E_NAME_L_INVALID);
         return;
     }
     if (!Utility::isValidEmail($email)) {
         $this->setError(self::$E_EMAIL_INVALID);
         return;
     }
     if (User::findByEmail($this->_pdo, $email)) {
         $this->setError(self::$E_USER_EXISTS);
         return;
     }
     if ($pledge_class == "") {
         $this->setError(self::$E_PLEDGE_CLASS_INVALID);
         return;
     }
     if (!Utility::cleanInt($_POST["year"], date("Y") - 6)) {
         $this->setError(self::$E_YEAR_INVALID);
         return;
     }
     if ($year === false) {
         $this->setError(self::$E_YEAR_INVALID);
         return;
     }
     if (!Utility::isValidPassword($password)) {
         $this->setError(self::$E_PASSWORD_INVALID);
         return;
     }
     $_chapter = new Chapter($this->_pdo);
     $_chapter->create($_org, $_uni);
     $_pc = new PledgeClass($this->_pdo);
     $_pc->create($_chapter, $pledge_class);
     $_user = new User($this->_pdo);
     $_user->create($_chapter, $_pc, $name_first, $name_last, $email, $password, $year, true);
     $worker = new EmailWorker($this->_pdo);
     //TODO: Send email to user about what's next
     $worker->queueSignUpNotificationEmail($_chapter);
 }
Beispiel #7
0
 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);
 }
Beispiel #8
0
        }
        return \FMA\User\User::findAllForChapterAsArray($_pdo, $chapter);
    });
    $router->map("GET", "/organization/[i:id]/chapter/[i:cid]/user/[i:uid]/", function ($id, $cid, $uid) use($_pdo) {
        $org = \FMA\Organization\GreekOrganization::find($_pdo, $id);
        if (is_null($org)) {
            return ["err" => true, "msg" => "No organization by that id."];
        }
        $chapter = \FMA\Organization\Chapter::find($_pdo, $cid);
        if (is_null($chapter)) {
            return ["err" => true, "msg" => "No chapter by that id."];
        }
        if ($chapter->getGreekOrganizationId() != $org->getId()) {
            return ["err" => true, "msg" => "Organization has no chapter by that id."];
        }
        $user = \FMA\User\User::find($_pdo, $uid);
        if (is_null($user)) {
            return ["err" => true, "msg" => "No user by that id."];
        }
        if ($user->getChapterId() != $chapter->getId()) {
            return ["err" => true, "msg" => "Chapter has no user by that id."];
        }
        return $user->toArray();
    });
}
$match = $router->match();
if ($match && !is_callable($match["target"])) {
    throw new TypeError("Target is not callable.");
} else {
    if ($match && is_callable($match["target"])) {
        $page_title = $match["name"];
Beispiel #9
0
 /**
  * @return User[]
  */
 public function getLittleBrothers() : array
 {
     if (!$this->_littles) {
         $this->_littles = User::findAllWithBigBrother($this->_pdo, $this->id);
     }
     return $this->_littles;
 }
Beispiel #10
0
 /**
  * @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);
     });
 }
Beispiel #11
0
 private function login(User $_user)
 {
     $this->_user = $_user;
     $_SESSION[self::$VALID_LOGIN] = $_user->getEmailUniversity();
     $_SESSION[self::$LAST_ACTION] = time();
 }
Beispiel #12
0
<?php

require_once __DIR__ . "/../../FMA/autoload.php";
$_pdo = new \FMA\PDO\MySQL_PDO();
$_auth = new \FMA\Auth\SessionAuth($_pdo);
$_auth->validate();
$_user = \FMA\User\User::find($_pdo, $_GET["id"]);
if (is_null($_user)) {
    header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found");
    exit;
}
$vCard = new \JeroenDesloovere\VCard\VCard();
$vCard->addName($_user->getNameLast(), $_user->getNameFirst());
$vCard->addPhoneNumber($_user->getPhoneNumber());
$vCard->addEmail($_user->getEmailUniversity());
$vCard->addCompany($_user->isBrother() ? "" : "Associate");
$vCard->addPhoto("http://" . \FMA\Config::getBaseUrl() . "/image/profile/large/" . $_user->getId());
$vCard->download();
Beispiel #13
0
 private function sendUserPasswordResetEmail(\int $user_id)
 {
     $_user = User::find($this->_pdo, $user_id);
     $this->_mailer->sendUserPasswordResetEmail($_user);
 }
Beispiel #14
0
 /**
  * @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);
     });
 }