Skip to content

Commit

Permalink
Merge pull request #40 from phpminds/develop
Browse files Browse the repository at this point in the history
Merge hotfix
  • Loading branch information
pavlakis committed Jan 6, 2016
2 parents 2af53f5 + c78d6e9 commit 4d349d9
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 34 deletions.
3 changes: 1 addition & 2 deletions app/src/Action/CreateEventAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function dispatch(Request $request, Response $response, $args)
$supporters = $this->eventManager->getSupporters();

$eventInfo = $this->eventService->getInfoByMeetupID($request->getParam('meetup_id'));
if ($eventInfo['event_exists']) {
if ($eventInfo->eventExists()) {
$this->flash->addMessage('event', 'Event already exists. Check its status.');
return $response->withStatus(302)->withHeader('Location', 'event-details?meetup_id=' . $request->getParam('meetup_id'));
}
Expand Down Expand Up @@ -146,7 +146,6 @@ public function dispatch(Request $request, Response $response, $args)

}


$nameKey = $this->csrf->getTokenNameKey();
$valueKey = $this->csrf->getTokenValueKey();

Expand Down
11 changes: 5 additions & 6 deletions app/src/Factory/EventFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ public static function getEvent($talkTitle, $talkDescription, $date, $speaker, $

public static function getMergedFromArrays(array $meetupEvent = [], array $dbEvent = null)
{
// echo '<pre>';
// var_dump($meetupEvent);exit;

if (!is_null($dbEvent)) {

$speaker = new Speaker(
Expand All @@ -52,8 +49,6 @@ public static function getMergedFromArrays(array $meetupEvent = [], array $dbEve
$dbEvent['avatar']
);



$supporter = new Supporter(
$dbEvent['supporter_name'], $dbEvent['supporter_url'],
new Twitter($dbEvent['supporter_twitter']),
Expand All @@ -70,7 +65,7 @@ public static function getMergedFromArrays(array $meetupEvent = [], array $dbEve
$talk = new Talk($meetupEvent['subject'], $meetupEvent['description'], $speaker);
$venue = new Venue($meetupEvent['venue_name'], $meetupEvent['venue_address']);

$date = \DateTime::createFromFormat('F jS Y', $meetupEvent['date']);
$date = \DateTime::createFromFormat('F jS Y g:ia', $meetupEvent['date'] . ' ' . $meetupEvent['time']);

$event = new EventModel(
$talk,
Expand All @@ -84,6 +79,10 @@ public static function getMergedFromArrays(array $meetupEvent = [], array $dbEve
$event->setMeetupID($meetupEvent['id']);
$event->setMeetupURL($meetupEvent['event_url']);

if (!is_null($dbEvent)) {
$event->eventExists();
}

return $event;
}
}
14 changes: 13 additions & 1 deletion app/src/Model/Event/EventModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class EventModel
*/
private $meetupURL;

private $eventExists = false;

public function __construct(TalkInterface $talk, \DateTime $date, VenueInterface $venue, SupporterInterface $supporter)
{
$this->talk = $talk;
Expand Down Expand Up @@ -89,7 +91,7 @@ public function setDescription($description)
/**
* @return Talk
*/
public function getTalk() : Talk
public function getTalk() : TalkInterface
{
return $this->talk;
}
Expand Down Expand Up @@ -178,4 +180,14 @@ public function setMeetupURL($meetupURL)
{
$this->meetupURL = $meetupURL;
}

public function setEventExists($exists = true)
{
$this->eventExists = $exists;
}

public function eventExists()
{
return $this->eventExists;
}
}
25 changes: 4 additions & 21 deletions app/src/Service/EventsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ public function getEventById($eventID)
{
$event = $this->meetupService->getEventById($eventID);
$eventInfo = $this->eventManager->getDetailsByMeetupID($event['id']);
return EventFactory::getMergedFromArrays($event, $eventInfo[0]);
$eventInfo = $eventInfo[0] ?? null;

return EventFactory::getMergedFromArrays($event, $eventInfo);
}

/**
Expand Down Expand Up @@ -117,26 +119,7 @@ public function getAll()
*/
public function getInfoByMeetupID($meetupID = null)
{
$eventInfo = ['title' => '', 'description' => '', 'event_exists'];

if (!is_null($meetupID)) {
$event = $this->getEventById((int)$meetupID);

if(!empty($event)) {

if (!empty($this->eventManager->getDetailsByMeetupID($meetupID))) {
$eventInfo['event_exists'] = true;
} else {
$eventInfo['title'] = $event['subject'];
$eventInfo['description'] = $event['description'];
$eventInfo['venue_id'] = $event['venue_id'];
$date = \DateTime::createFromFormat('F jS Y', $event['date']);
$eventInfo['date'] = $date->format("d/m/Y");
}
}
}

return $eventInfo;
return $this->getEventById((int)$meetupID);

}

Expand Down
12 changes: 8 additions & 4 deletions app/templates/admin/create-event.twig
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<select id="venues" name="venue">
<option value="0">-- Select --</option>
{% for venue in venues %}
<option {% if eventInfo.venue_id == venue.id %}selected{% endif %} value="{{ venue.id }}">{{ venue.name }} - {{ venue.address }}</option>
<option {% if eventInfo.getVenueId == venue.id %}selected{% endif %} value="{{ venue.id }}">{{ venue.name }} - {{ venue.address }}</option>
{% endfor %}
</select>
</div>
Expand All @@ -79,7 +79,7 @@
<label class="inline">Date</label>
</div>
<div class="large-5 medium-4 columns">
<input placeholder="Date" name="start_date" class="textbox-n" type="text" onfocus="(this.type='date')" {% if eventInfo.date is defined %}value="{{ eventInfo.date }}"{% endif %} id="date">
<input placeholder="Date" name="start_date" class="textbox-n" type="text" onfocus="(this.type='date')" {% if eventInfo.getMeetupID %}value="{{ eventInfo.getDate().format('d/m/Y') }}"{% endif %} id="date">
</div>
<div class="large-2 columns"></div>
</div>
Expand All @@ -93,6 +93,10 @@
{% for i in 8..22 %}
<option value="{{ i }}:00">{{ i }}:00</option>
{% endfor %}
{% if eventInfo.getMeetupID %}
<option value="{{ eventInfo.getDate().format('H:i') }}" selected>{{ eventInfo.getDate().format('H:i') }}</option>
{% endif %}

</select>
</div>
<div class="large-5 columns"></div>
Expand All @@ -103,13 +107,13 @@
<label class="inline">Talk Title</label>
</div>
<div class="large-10 medium-5 columns">
<input type="text" id="talk_title" name="talk_title" placeholder="Talk title" value="{{ eventInfo.title }}">
<input type="text" id="talk_title" name="talk_title" placeholder="Talk title" value="{{ eventInfo.getTalk().getTitle() }}">
</div>
</div>

<div class="row large-10 medium-5 collapse">
<label>Talk description / Abstract</label>
<textarea name="talk_description" id="talk_description" rows="4">{{ eventInfo.description }}</textarea>
<textarea name="talk_description" id="talk_description" rows="4">{{ eventInfo.getTalk().getDescription() }}</textarea>
</div>
<button type="submit" class="radius button">Submit</button>
</form>
Expand Down

0 comments on commit 4d349d9

Please sign in to comment.