Ejemplo n.º 1
0
 /**
  * @param BasePDO $_pdo
  * @param FilesystemInterface $_fs
  * @param Event $_e
  * @return File[]
  */
 public static function findForEvent(BasePDO $_pdo, FilesystemInterface $_fs, Event $_e) : array
 {
     $query = "SELECT f.*\n\t\t\t\t\t  FROM `file` f RIGHT JOIN rel_file_event rfe ON f.id = rfe.file_id\n\t\t\t\t\t  WHERE rfe.event_id = :eid";
     return $_pdo->fetchAssoc($query, ["eid" => $_e->getId()], function ($row) use($_pdo, $_fs) {
         return new File($_pdo, $_fs, $row);
     });
 }
Ejemplo n.º 2
0
 public function sendChapterMeetingEmail(Event $_event, FilesystemInterface $_fs)
 {
     $_chapter = $_event->getCreator()->getChapter();
     $_brothers = User::findAllActiveBrothersForChapter($this->_pdo, $_chapter);
     $_files = EventFileBuilder::findForEvent($this->_pdo, $_fs, $_event);
     foreach ($_brothers as $_brother) {
         $this->send(self::$T_CHAPTER_MEETING, $_brother, ["NAME" => $_brother->getNameFull(), "SECRETARY" => $_event->getCreator()->getNameFull(), "MEETING_DATE" => $_event->getDateCreated()->format("J d, Y"), "FILE_COUNT" => count($_files)]);
     }
 }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
<?php

$events = array_map(function (\FMA\Calendar\Event $row) {
    return $row->toArray();
}, \FMA\Calendar\Event::findAllForChapter($_pdo, $_auth->getUser()->getChapter()));
?>
<div id="calendar-container">
	<div id="header-data">
		<span id="cal-title"></span>
		<div id="controls">
			<div id="movements">
				<div id="prev" class="control arrow icon-left-dir"></div>
				<div id="today" class="control text">Today</div>
				<div id="next" class="control arrow icon-right-dir"></div>
			</div>
			<div id="views">
				<div class="view control text" data-view="day">Day</div>
				<div class="view control text" data-view="week">Week</div>
				<div class="view control text active" data-view="month">Month</div>
			</div>
		</div>
	</div>
<!--	<div id="header-row">-->
<!--		<div class="day-column weekend">Sun</div>-->
<!--		<div class="day-column">Mon</div>-->
<!--		<div class="day-column">Tue</div>-->
<!--		<div class="day-column">Wed</div>-->
<!--		<div class="day-column">Thu</div>-->
<!--		<div class="day-column">Fri</div>-->
<!--		<div class="day-column weekend">Sat</div>-->
<!--	</div>-->
Ejemplo n.º 5
0
$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
                } catch (\FMA\Exception\UploadException $er) {
                    $data = array("err" => true, "msg" => $er->getMessage());
                }
            }
        }
Ejemplo n.º 6
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);
 }
Ejemplo n.º 7
0
 private function sendChapterMeetingEmail(\int $event_id)
 {
     $_event = Event::find($this->_pdo, $event_id);
     $this->_mailer->sendChapterMeetingEmail($_event, Config::getFileSystem());
 }