Exemplo n.º 1
0
 public function create(Chapter $_chapter, PledgeClass $_pledge_class, string $name_first, string $name_last, string $email_university, string $password, DateTime $date_started_university, bool $is_brother, string $email_alternate = "", string $phone_number = "", string $university_identifier = "", string $address_line_1 = "", string $address_line_2 = "", string $address_city = "", string $address_state = "", string $address_zip = "")
 {
     $this->_chapter = $_chapter;
     $this->_pledge_class = $_pledge_class;
     $query = "INSERT INTO `user`\n\t\t\t\t\t    (chapter_id, pledge_class_id, name_first, name_last, name_link, name_link_duplicate,\n\t\t\t\t\t     email_university, email_alternate, phone_number, university_identifier, address_line_1,\n\t\t\t\t\t     address_line_2, address_city, address_state, address_zip, date_started_university,\n\t\t\t\t\t     date_joined, password_hash, token_value_account_verify, token_expiry_account_verify,\n\t\t\t\t\t     is_brother)\n\t\t\t\t\t  SELECT\n\t\t\t\t\t    :cid, :pid, :nf, :nl, :nli, coalesce(max(name_link_duplicate) + 1, 0),\n\t\t\t\t\t    :eu, :ea, :pn, :uid, :adl1, :adl2, :adc, :ads, :adz, :ys, :tj, :ph, :tv, :te, :ib\n\t\t\t\t\t  FROM user\n\t\t\t\t\t  WHERE name_link = :nli AND chapter_id = :cid";
     $this->_pdo->perform($query, ["cid" => $this->chapter_id = $_chapter->getId(), "pid" => $this->pledge_class_id = $_pledge_class->getId(), "nf" => $this->name_first = $name_first, "nl" => $this->name_last = $name_last, "nli" => $this->name_link = Utility::getNameLink($name_last), "eu" => $this->email_university = $email_university, "ea" => $this->email_alternate = $email_alternate, "pn" => $this->phone_number = $phone_number, "uid" => $this->university_identifier = $university_identifier, "adl1" => $this->address_line_1 = $address_line_1, "adl2" => $this->address_line_2 = $address_line_2, "adc" => $this->address_city = $address_city, "ads" => $this->address_state = $address_state, "adz" => $this->address_zip = $address_zip, "ys" => $this->date_started_university = Utility::getDateTimeForMySQLDate($date_started_university), "tj" => $this->date_joined = Utility::getDateTimeForMySQLDate(), "ph" => $this->password_hash = Utility::hashPassword($password), "tv" => $this->token_value_account_verify = Utility::getRandomString(60), "te" => $this->token_expiry_account_verify = Utility::getExpiryAsMySQLDateTime("15 days"), "ib" => $this->is_brother = $is_brother]);
     $this->id = $this->_pdo->lastInsertId();
 }
Exemplo n.º 2
0
 /**
  * @return Event[]
  */
 public function generateEvents()
 {
     $start = new DateTime($this->start);
     $end = new DateTime($this->end);
     $end = $end->add($start->diff($end));
     switch ($this->repeat_type) {
         case self::TYPE_WEEKS:
             $interval = DateInterval::createFromDateString("1 week");
             break;
         case self::TYPE_MONTHS:
             $interval = DateInterval::createFromDateString("1 month");
             break;
         case self::TYPE_YEARS:
             $interval = DateInterval::createFromDateString("1 year");
             break;
         default:
             $interval = DateInterval::createFromDateString("1 day");
             break;
     }
     $_existing_events = Event::findAllForGroup($this->_pdo, $this);
     $_existing_events_keyed = [];
     foreach ($_existing_events as $_existing_event) {
         $key = Utility::getDateTimeForMySQLDate($_existing_event->getStart());
         $_existing_events_keyed[$key] = $_existing_event;
     }
     $_events = [];
     while (count($_events) < $this->n_times) {
         if (array_key_exists(Utility::getDateTimeForMySQLDate($start), $_existing_events_keyed)) {
             continue;
         }
         $_event = new Event($this->_pdo);
         $_event->create($this->name, $this->notes, $this->all_day_event, $this->is_chapter, $this->getCreator(), $end, $start, $this->id);
         $_events[] = $_event;
         $start->add($interval);
         $end->add($interval);
     }
     return array_merge($_existing_events, $_events);
 }