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);
 }
示例#2
0
文件: User.php 项目: stevenimle/GMA
 public function getPledgeClass() : PledgeClass
 {
     if (!$this->_pledge_class) {
         $this->_pledge_class = PledgeClass::find($this->_pdo, $this->pledge_class_id);
     }
     return $this->_pledge_class;
 }