Skip to content

Commit

Permalink
Fix team id to group id
Browse files Browse the repository at this point in the history
  • Loading branch information
kveldscholten committed Apr 3, 2017
1 parent 0b630a9 commit a3d6270
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 28 deletions.
2 changes: 2 additions & 0 deletions application/modules/teams/controllers/Index.php
Expand Up @@ -21,6 +21,8 @@ public function indexAction()
$userMapper = new UserMapper();
$groupMapper = new GroupMapper();

$this->getLayout()->header()
->css('static/css/teams.css');
$this->getLayout()->getTitle()
->add($this->getTranslator()->trans('menuTeams'));
$this->getLayout()->getHmenu()
Expand Down
35 changes: 20 additions & 15 deletions application/modules/teams/controllers/admin/Applications.php
Expand Up @@ -50,33 +50,33 @@ public function indexAction()
$joinsMapper = new JoinsMapper();
$teamsMapper = new TeamsMapper();

$this->addMessage('rightsOfGroup', 'danger');

$this->getLayout()->getAdminHmenu()
->add($this->getTranslator()->trans('menuTeams'), ['controller' => 'index', 'action' => 'index'])
->add($this->getTranslator()->trans('menuApplications'), ['action' => 'index']);
->add($this->getTranslator()->trans('menuTeams'), ['controller' => 'index', 'action' => 'index'])
->add($this->getTranslator()->trans('menuApplications'), ['action' => 'index']);

$this->getView()->set('teamsMapper', $teamsMapper);
$this->getView()->set('joins', $joinsMapper->getJoins());
$this->addMessage('rightsOfGroup', 'danger');

$this->getView()->set('teamsMapper', $teamsMapper)
->set('joins', $joinsMapper->getJoins());
}

public function showAction()
{
$joinsMapper = new JoinsMapper();
$teamsMapper = new TeamsMapper();

$this->addMessage('rightsOfGroup', 'danger');

$join = $joinsMapper->getJoinById($this->getRequest()->getParam('id'));

$this->getLayout()->getAdminHmenu()
->add($this->getTranslator()->trans('menuTeams'), ['controller' => 'index', 'action' => 'index'])
->add($this->getTranslator()->trans('menuApplications'), ['controller' => 'applications', 'action' => 'index'])
->add($join->getName(), ['action' => 'show', 'id' => $this->getRequest()->getParam('id')]);

$this->getView()->set('joinsMapper', $joinsMapper);
$this->getView()->set('teamsMapper', $teamsMapper);
$this->getView()->set('join', $join);
$this->addMessage('rightsOfGroup', 'danger');

$this->getView()->set('joinsMapper', $joinsMapper)
->set('teamsMapper', $teamsMapper)
->set('join', $join);
}

public function acceptAction()
Expand All @@ -86,7 +86,6 @@ public function acceptAction()
$teamsMapper = new TeamsMapper();
$userMapper = new UserMapper();
$passwordService = new PasswordService();
$date = new \Ilch\Date();

$join = $joinsMapper->getJoinById($this->getRequest()->getParam('id'));
$name = $join->getName();
Expand All @@ -107,20 +106,26 @@ public function acceptAction()
$password = substr(str_shuffle($password_string), 0, 12);

$userModel = new UserModel();
if ($join->getPlace()) {
$userModel->setCity($join->getPlace());
}
$userModel->setName($name)
->setPassword($passwordService->hash($password))
->setEmail($email)
->setDateCreated($date->format("Y-m-d H:i:s", true))
->setBirthday($join->getBirthday())
->setGender($join->getGender())
->setDateCreated($join->getDateCreated())
->addGroup($userGroup)
->setSelector($selector)
->setConfirmedCode($confirmedCode)
->setConfirmed(0);
$userMapper->save($userModel);
}

$team = $teamsMapper->getTeamById($join->getTeamId());
$team = $teamsMapper->getTeamByGroupId($join->getTeamId());
$teamname = $team->getName();
$sitetitle = $this->getConfig()->get('page_title');
$date = new \Ilch\Date();

$layout = '';
if (!empty($_SESSION['layout'])) {
Expand Down Expand Up @@ -173,7 +178,7 @@ public function rejectAction()
$teamsMapper = new TeamsMapper();

$join = $joinsMapper->getJoinById($this->getRequest()->getParam('id'));
$team = $teamsMapper->getTeamById($join->getTeamId());
$team = $teamsMapper->getTeamByGroupId($join->getTeamId());
$name = $join->getName();
$email = $join->getEmail();
$teamname = $team->getName();
Expand Down
13 changes: 13 additions & 0 deletions application/modules/teams/mappers/Teams.php
Expand Up @@ -58,6 +58,19 @@ public function getTeamById($id)
return reset($team);
}

/**
* Get Team by given group id.
*
* @param integer $id
* @return TeamsModel|null
*/
public function getTeamByGroupId($id)
{
$team = $this->getTeams(['groupId' => $id]);

return reset($team);
}

/**
* Delete/Unlink Image by Id.
*
Expand Down
12 changes: 6 additions & 6 deletions application/modules/teams/models/Joins.php
Expand Up @@ -203,7 +203,7 @@ public function setGender($gender)
/**
* Gets the Birthday of the User.
*
* @return string
* @return \Ilch\Date
*/
public function getBirthday()
{
Expand All @@ -213,12 +213,12 @@ public function getBirthday()
/**
* Sets the Birthday of the User.
*
* @param string $birthday
* @param \Ilch\Date $birthday
* @return $this
*/
public function setBirthday($birthday)
{
$this->birthday = (string)$birthday;
$this->birthday = $birthday;

return $this;
}
Expand Down Expand Up @@ -295,20 +295,20 @@ public function setTeamId($teamId)
/**
* Sets the created Date of the Join.
*
* @param string $dateCreated
* @param \Ilch\Date $dateCreated
* @return $this
*/
public function setDateCreated($dateCreated)
{
$this->dateCreated = (string)$dateCreated;
$this->dateCreated = $dateCreated;

return $this;
}

/**
* Gets the created Date of the Join.
*
* @return string
* @return \Ilch\Date
*/
public function getDateCreated()
{
Expand Down
Expand Up @@ -17,7 +17,7 @@
</thead>
<tbody>
<?php foreach ($this->get('joins') as $join): ?>
<?php $team = $teamsMapper->getTeamById($join->getTeamId()); ?>
<?php $team = $teamsMapper->getTeamByGroupId($join->getTeamId()); ?>
<?php $date = new Ilch\Date($join->getDateCreated()); ?>
<tr>
<td><a href="<?=$this->getUrl(['action' => 'show', 'id' => $join->getId()]) ?>" title="<?=$this->getTrans('show') ?>"><?=$this->escape($join->getName()) ?></a></td>
Expand Down
9 changes: 9 additions & 0 deletions application/modules/teams/views/admin/applications/show.php
Expand Up @@ -6,6 +6,7 @@
<h1><?=$this->getTrans('application') ?></h1>
<?php if ($this->get('join')): ?>
<?php $join = $this->get('join'); ?>
<?php $team = $teamsMapper->getTeamByGroupId($join->getTeamId()); ?>
<?php $date = new Ilch\Date($join->getDateCreated()); ?>
<?php $birthday = new Ilch\Date($join->getBirthday()); ?>
<div class="form-horizontal">
Expand All @@ -17,6 +18,14 @@
<?=$join->getName() ?>
</div>
</div>
<div class="form-group">
<label class="col-lg-2">
<?=$this->getTrans('team') ?>:
</label>
<div class="col-lg-2">
<?=$team->getName() ?>
</div>
</div>
<div class="form-group">
<label class="col-lg-2">
<?=$this->getTrans('email') ?>:
Expand Down
5 changes: 1 addition & 4 deletions application/modules/teams/views/index/index.php
Expand Up @@ -3,8 +3,6 @@
$groupMapper = $this->get('groupMapper');
?>

<link href="<?=$this->getModuleUrl('static/css/teams.css') ?>" rel="stylesheet">

<h1><?=$this->getTrans('menuTeams') ?></h1>
<div class="teams">
<?php if ($this->get('teams')): ?>
Expand Down Expand Up @@ -34,7 +32,7 @@
<tbody>
<?php foreach ($groupList as $userId): ?>
<?php $user = $userMapper->getUserById($userId); ?>
<?php if ($user): ?>
<?php if ($user AND $user->getConfirmed() == 1): ?>
<tr>
<td>
<a href="<?=$this->getUrl(['module' => 'user', 'controller' => 'profil', 'action' => 'index', 'user' => $user->getId()]) ?>" title="<?=$this->escape($user->getName()) ?>s <?=$this->getTrans('profile') ?>">
Expand Down Expand Up @@ -76,7 +74,6 @@
<?php endif; ?>
<?php endforeach; ?>


<?php ($this->getUser()) ? $userId = $this->getUser()->getId() : $userId = 0 ?>
<?php if ($teamlist->getOptIn() == 1 AND (!in_array($userId, $groupList) OR $userId == 0)): ?>
<tr>
Expand Down
4 changes: 2 additions & 2 deletions application/modules/teams/views/index/join.php
Expand Up @@ -30,10 +30,10 @@

if ($teamList->getOptIn() == 1 AND (!in_array($userId, $groupList) OR $userId == 0)) {
$selected = '';
if ($this->originalInput('teamId') == $teamList->getId() OR $this->getRequest()->getParam('id') == $teamList->getId()) {
if ($this->originalInput('teamId') == $teamList->getGroupId() OR $this->getRequest()->getParam('id') == $teamList->getId()) {
$selected = 'selected="selected"';
}
echo '<option '.$selected.' value="'.$teamList->getId().'">'.$teamList->getName().'</option>';
echo '<option '.$selected.' value="'.$teamList->getGroupId().'">'.$teamList->getName().'</option>';
}
} ?>
</optgroup>
Expand Down

0 comments on commit a3d6270

Please sign in to comment.