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);
 }
Example #2
0
 /**
  * @param BasePDO $_pdo
  * @param GreekOrganization $_org
  * @return array[]
  */
 public static function findAllForGreekOrganizationAsArray(BasePDO $_pdo, GreekOrganization $_org) : array
 {
     return $_pdo->fetchAssoc("SELECT * FROM chapter WHERE greek_organization_id = :id", ["id" => $_org->getId()]);
 }
Example #3
0
 $router->map("GET", "/organization/[i:id]/chapter/[i:cid]/user/", function ($id, $cid) 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."];
     }
     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()) {