Skip to content

Commit

Permalink
Merge pull request #43 from phpminds/develop
Browse files Browse the repository at this point in the history
Updating contact us. Fixing joindin talks syncing.
  • Loading branch information
pavlakis committed Jan 12, 2016
2 parents 4d349d9 + 5ade07c commit 4f5c766
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 68 deletions.
26 changes: 22 additions & 4 deletions app/src/Factory/EventFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ public static function getEvent($talkTitle, $talkDescription, $date, $speaker, $

public static function getMergedFromArrays(array $meetupEvent = [], array $dbEvent = null)
{
if (empty($meetupEvent)) {

$supporter = new NullSupporter();
$date = new \DateTime();
$talk = new NullTalk();
$venue = new NullVenue();

$model = new EventModel(
$talk,
$date,
$venue,
$supporter
);

return $model;

}
if (!is_null($dbEvent)) {

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

$speaker->setId($dbEvent['speaker_id']);

$supporter = new Supporter(
$dbEvent['supporter_name'], $dbEvent['supporter_url'],
new Twitter($dbEvent['supporter_twitter']),
new Email($dbEvent['supporter_email']),
$dbEvent['supporter_logo']
);

$supporter->setId($dbEvent['supporter_id']);


} else {
$speaker = new NullSpeaker();
Expand All @@ -64,6 +85,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']);
$venue->setId($meetupEvent['venue_id']);

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

Expand All @@ -79,10 +101,6 @@ 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;
}
}
5 changes: 5 additions & 0 deletions app/src/Model/Event/Entity/Speaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,9 @@ public static function create(array $params = []) : Speaker
return $class;
}

public function exists()
{
return true;
}

}
4 changes: 2 additions & 2 deletions app/src/Model/Event/Entity/Talk.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ public static function create(array $params = []) : TalkInterface
$params['description'] ?? null,
$params['speaker'], // Expects Speaker object
$params['duration'],
$params['slides']
$params['slides'] ?? ''
);

$class->setId($params['id']);
$class->setId($params['id'] ?? '');

return $class;
}
Expand Down
17 changes: 7 additions & 10 deletions app/src/Model/Event/EventModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ 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 @@ -120,15 +118,15 @@ public function getDateTimeAsString()
/**
* @return Venue
*/
public function getVenue() : Venue
public function getVenue() : VenueInterface
{
return $this->venue;
}

/**
* @return Supporter
*/
public function getSupporter() : Supporter
public function getSupporter() : SupporterInterface
{
return $this->supporter;
}
Expand Down Expand Up @@ -181,13 +179,12 @@ public function setMeetupURL($meetupURL)
$this->meetupURL = $meetupURL;
}

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

/**
* An event exists (locally) if it has a Speaker associated with it.
* @return bool
*/
public function eventExists()
{
return $this->eventExists;
return $this->getTalk()->getSpeaker()->exists();
}
}
5 changes: 5 additions & 0 deletions app/src/Model/Event/NullSpeaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ public function getTwitter()
{
return '';
}

public function exists()
{
return false;
}
}
2 changes: 2 additions & 0 deletions app/src/Model/Event/SpeakerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ public function getLastName();
public function getEmail();

public function getTwitter();

public function exists();
}
16 changes: 8 additions & 8 deletions app/src/Repository/EventsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ public function update(Event $event)
. ' WHERE meetup_id = :meetup_id';

$stmt = $this->db->prepare($sql);
$stmt->bindParam(":meetup_id", $event->getMeetupID(), \PDO::PARAM_INT);
$stmt->bindParam(":meetup_venue_id", $event->getMeetupVenueID(), \PDO::PARAM_INT);
$stmt->bindParam(":joindin_event_name", $event->getJoindinEventName(), \PDO::PARAM_STR);
$stmt->bindParam(":joindin_talk_id", $event->getJoindinTalkID(), \PDO::PARAM_INT);
$stmt->bindParam(":joindin_url", $event->getJoindinURL(), \PDO::PARAM_STR);
$stmt->bindParam(":speaker_id", $event->getSpeakerID(), \PDO::PARAM_INT);
$stmt->bindParam(":supporter_id", $event->getSupporterID(), \PDO::PARAM_INT);
$stmt->bindParam(":meetup_date", $event->getMeetupDate()->format('Y-m-d H:i:s'), \PDO::PARAM_STR);
$stmt->bindValue(":meetup_id", $event->getMeetupID(), \PDO::PARAM_INT);
$stmt->bindValue(":meetup_venue_id", $event->getMeetupVenueID(), \PDO::PARAM_INT);
$stmt->bindValue(":joindin_event_name", $event->getJoindinEventName(), \PDO::PARAM_STR);
$stmt->bindValue(":joindin_talk_id", $event->getJoindinTalkID(), \PDO::PARAM_INT);
$stmt->bindValue(":joindin_url", $event->getJoindinURL(), \PDO::PARAM_STR);
$stmt->bindValue(":speaker_id", $event->getSpeakerID(), \PDO::PARAM_INT);
$stmt->bindValue(":supporter_id", $event->getSupporterID(), \PDO::PARAM_INT);
$stmt->bindValue(":meetup_date", $event->getMeetupDate()->format('Y-m-d H:i:s'), \PDO::PARAM_STR);


return $stmt->execute();
Expand Down
36 changes: 11 additions & 25 deletions app/src/Service/EventsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ public function getPastEvents()
* @param $eventID
* @return \PHPMinds\Model\Event\EventModel
*/
public function getEventById($eventID)
public function getEventById($eventID = null)
{
$event = $this->meetupService->getEventById($eventID);
$event = $this->meetupService->getEventById($eventID);
$eventInfo = $this->eventManager->getDetailsByMeetupID($event['id']);
$eventInfo = $eventInfo[0] ?? null;

Expand All @@ -107,6 +107,11 @@ public function getAll()
$event,
$eventDetails[$event['id']]
);
} else {
$result[] = EventFactory::getMergedFromArrays(
$event,
null
);
}
}

Expand All @@ -115,11 +120,11 @@ public function getAll()

/**
* @param int $meetupID
* @return array
* @return \PHPMinds\Model\Event\EventModel
*/
public function getInfoByMeetupID($meetupID = null)
{
return $this->getEventById((int)$meetupID);
return $this->getEventById($meetupID);

}

Expand Down Expand Up @@ -299,30 +304,11 @@ public function manageApprovedEvents($userID)
foreach ($events as $eventName => $event) {

// API call
/** @var EventModel $meetupEvent */
$meetupEvent = $this->getEventById($event->meetup_id);
$this->getMeetupEvent()->setEventID($event->meetup_id);

$speaker = $this->eventManager->getSpeakerById($event->speaker_id);
$supporter = $this->eventManager->getSupporterByID($event->supporter_id);
$venue = $this->getVenueById($meetupEvent['venue_id']);

$talk = Talk::create([
'title' => $meetupEvent['subject'],
'description' => $meetupEvent['description'],
'speaker' => $speaker,
'duration' => 'PT2H' // default to 2 hours
]);

$this->event = new EventModel(
$talk,
\DateTime::createFromFormat(
"F jS Y g:ia",
$meetupEvent['date'] . ' ' . $meetupEvent['time']
),
$venue,
$supporter
);

$this->event = $meetupEvent;
$this->joindinEventService->getJoindinEvent()->setEventLocation($event->uri);
if ($this->createJoindinTalk($userID)->getStatusCode() !== 201) {
throw new \Exception('Could not create Joindin Talk');
Expand Down
16 changes: 13 additions & 3 deletions app/src/Service/MeetupService.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,17 @@ public function getPastEvents($savedEvents = null)
$this->meetupEvent->formatResponse($event),
$savedEvents[$event['id']]
);
} else {
$pastEvents[] = EventFactory::getMergedFromArrays(
$this->meetupEvent->formatResponse($event),
null
);
}
} else {
$pastEvents[] = $this->meetupEvent->formatResponse($event);
$pastEvents[] = EventFactory::getMergedFromArrays(
$this->meetupEvent->formatResponse($event),
null
);
}
}

Expand All @@ -116,9 +124,11 @@ public function createMeetup(EventModel $event)
return $response;
}

public function getEventById($eventID)
public function getEventById($eventID = null)
{
$result = $this->client->getEvent(['id' => $eventID, 'group_urlname' => $this->config->groupUrlName])->getData();
if (!is_null($eventID)) {
$result = $this->client->getEvent(['id' => $eventID, 'group_urlname' => $this->config->groupUrlName])->getData();
}

return $this->meetupEvent->formatResponse($result ?? []);
}
Expand Down
6 changes: 3 additions & 3 deletions app/templates/admin/create-event.twig
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<select id="supporters" name="supporter">
<option value="0">-- Select --</option>
{% for supporter in supporters %}
<option value="{{ supporter.id }}">{{ supporter.name }} ({{ supporter.twitter }})</option>
<option {% if eventInfo.getSupporter().getId() == supporter.id %}selected{% endif %} value="{{ supporter.id }}">{{ supporter.name }} ({{ supporter.twitter }})</option>
{% endfor %}
</select>

Expand All @@ -51,7 +51,7 @@
<option value="0">-- Select --</option>
<option value="-1">Create speaker</option>
{% for speaker in speakers %}
<option value="{{ speaker.id }}">{{ speaker.firstName }} {{ speaker.lastName }} ({{ speaker.twitter }})</option>
<option {% if eventInfo.getTalk().getSpeaker().getId() == speaker.id %}selected{% endif %} value="{{ speaker.id }}">{{ speaker.firstName }} {{ speaker.lastName }} ({{ speaker.twitter }})</option>
{% endfor %}
</select>

Expand All @@ -67,7 +67,7 @@
<select id="venues" name="venue">
<option value="0">-- Select --</option>
{% for venue in venues %}
<option {% if eventInfo.getVenueId == venue.id %}selected{% endif %} value="{{ venue.id }}">{{ venue.name }} - {{ venue.address }}</option>
<option {% if eventInfo.getVenue().getId() == venue.id %}selected{% endif %} value="{{ venue.id }}">{{ venue.name }} - {{ venue.address }}</option>
{% endfor %}
</select>
</div>
Expand Down
18 changes: 7 additions & 11 deletions app/templates/home.twig
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,14 @@
</section>
<section class="section-lite-green contact" id="contact">
<div class="row">
<div class="large-10 large-offset-1 small-12 columns">
<h3><i class="fa fa-envelope-o"></i>Contact us </h3>


<div class="small-12 medium-4 large-4 columns">
<p><a href="https://twitter.com/phpminds">twitter : @phpminds</a></p>
</div>
<div class="small-12 medium-4 large-4 columns">
<p><a href="http://slack.phpminds.org/">slack : < slack.phpminds.org ></a></p>
<p><a href="https://www.irccloud.com/#!/ircs://irc.freenode.net:6697/%23phpminds">irc : #freenode phpminds</a></p>
</div>
</div>
<div class="small-12 small-centered medium-8 medium-centered large-10 large-centered columns">
<h3>Contact us </h3>
<ul class="contact-details">
<li><a href="https://twitter.com/phpminds"><i class="fa fa-slack"> </i>Slack </a></li>
<li><a href="http://slack.phpminds.org/"><i class="fa fa-twitter-square "></i>@phpminds</a></li>
<li><a href="https://www.irccloud.com/#!/ircs://irc.freenode.net:6697/%23phpminds"><i class="fa fa-comment"></i>#freenode</a></li>
</ul>
</div>
</div>
</section>
Expand Down
23 changes: 23 additions & 0 deletions build/sass/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ html {

}





footer {
text-align: center;
color: $white-smoke;
Expand Down Expand Up @@ -302,4 +306,23 @@ html {
background: $lite-green;
}
}
ul.contact-details {
text-align: center;
list-style-type: none;
margin: 0;
padding: 0;
font-size: 1.2em;
li {
display: inline-flex;
flex: 1;
padding: 5%;
color: #6aa84f;
vertical-align: middle;
i:after{
margin: 0.5em;
}
}


}
}
4 changes: 2 additions & 2 deletions public/css/style.css

Large diffs are not rendered by default.

0 comments on commit 4f5c766

Please sign in to comment.