public function main() { $name = Utility::cleanString($_POST["name"]); $notes = Utility::cleanString($_POST["notes"]); $is_chapter = Utility::cleanBoolean($_POST["is_chapter"]); $all_day_event = !$is_chapter && Utility::cleanBoolean($_POST["is_all_day"]); $start = Utility::getDateTimeFromDateYmdHis(Utility::cleanString($_POST["time_start"])); $end = Utility::getDateTimeFromDateYmdHis(Utility::cleanString($_POST["time_end"])); $is_repeating = !$is_chapter && Utility::cleanBoolean($_POST["is_repeating"]); $n_times = Utility::cleanInt($_POST["n_times"], 2); $repeat_type = Utility::cleanInt($_POST["repeat_type"], Group::TYPE_DAYS, Group::TYPE_YEARS); if ($name == "") { $this->setError(self::$E_INVALID_NAME); } else { if (!$all_day_event && !$start) { $this->setError(self::$E_INVALID_DATE_START); } else { if (!$all_day_event && !$is_chapter && !$end) { $this->setError(self::$E_INVALID_DATE_END); } else { if (!$all_day_event && $end <= $start) { $this->setError(self::$E_INVALID_DATE_END_BEFORE_START); } else { if ($is_repeating) { if ($n_times === false) { $this->setError(self::$E_INVALID_REPEAT_TIME); } else { if ($repeat_type === false) { $this->setError(self::$E_INVALID_REPEAT_TYPE); } } } } } } } if ($this->hasError()) { return []; } $_events = []; if ($all_day_event) { $start = $start ?: null; $end = $end ?: null; } if (!$is_repeating) { $_event = new Event($this->_pdo); $_event->create($name, $notes, $all_day_event, $is_chapter, $this->_auth->getUser(), $end, $start); $_events[] = $_event; } else { $_group = new Group($this->_pdo); $_group->create($name, $notes, $all_day_event, $is_chapter, $n_times, $this->_auth->getUser(), $repeat_type, $start, $end); $_events = $_group->generateEvents(); } return $_events; }
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); }
header("Content-Type: application/json"); require_once __DIR__ . "/../../FMA/autoload.php"; $_pdo = new \FMA\PDO\MySQL_PDO(); $_auth = new \FMA\Auth\SessionAuth($_pdo); $_auth->validate(); $data = []; if (!count($_FILES)) { $data = ["err" => true, "msg" => "There was an error with the file upload."]; } else { if (\FMA\Utility::stringStartsWith($_REQUEST["REQUEST_NAME"], "ADMIN_")) { $_REQUEST["REQUEST_NAME"] = str_replace("ADMIN_", "", $_REQUEST["REQUEST_NAME"]); if (!$_auth->getUser()->getPosition() || !$_auth->getUser()->getPosition()->isOfficer()) { $data = ["err" => true, "msg" => "You do not have permission to do that."]; } else { if ($_REQUEST["DATA_TYPE"] == "UPLOAD_EVENT_ATTACHMENT") { $event_id = Utility::cleanInt($_POST["event_id"], 1); if (!$event_id) { $data = ["err" => true, "msg" => "Invalid event ID."]; goto end; } $_event = \FMA\Calendar\Event::find($_pdo, $event_id); if (is_null($_event) || $_event->getCreator()->getChapterId() != $_auth->getUser()->getChapterId()) { $data = ["err" => true, "msg" => "Invalid event ID."]; goto end; } try { $_fs = \FMA\Config::getFileSystem(); $_uploader = new \FMA\File\Builder\EventFileBuilder($_pdo, $_fs, $_event); $_file = $_uploader->create($_auth->getUser(), $_FILES["event_attachment"]); $data = ["err" => false, "msg" => "", "file" => $_file->toArray()]; //TODO: Decide if an email should be sent here