Skip to content

Commit

Permalink
Merge pull request #706 from hhunderter/v2.1.51
Browse files Browse the repository at this point in the history
V2.1.51
  • Loading branch information
hhunderter authored Jul 16, 2023
2 parents b66ff75 + a5bbdda commit 286d770
Show file tree
Hide file tree
Showing 27 changed files with 184 additions and 78 deletions.
6 changes: 3 additions & 3 deletions application/modules/admin/layouts/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@

/** @var \Modules\Admin\Models\Module $module */
foreach ($this->get('modules') as $module) {
if ($user->hasAccess('module_' . $module->getKey()) || ($module->getKey() == 'article' && $accesses->hasAccess('Admin', null, $accesses::TYPE_ARTICLE))) {
if ($user->hasAccess('module_' . $module->getKey()) || ($module->getKey() == 'article' && ($accesses && $accesses->hasAccess('Admin', null, $accesses::TYPE_ARTICLE)))) {
$content = $module->getContentForLocale($this->getTranslator()->getLocale());
if (strncmp($module->getIconSmall(), 'fa-', 3) === 0) {
$smallIcon = '<i class="fa ' . $module->getIconSmall() . '" style="padding-right: 5px;"></i>';
Expand Down Expand Up @@ -179,14 +179,14 @@
</ul>
</li>
<?php endif; ?>
<?php if ($accesses->hasAccess('Admin', null, $accesses::TYPE_PAGE)) : ?>
<?php if ($accesses && $accesses->hasAccess('Admin', null, $accesses::TYPE_PAGE)) : ?>
<li <?=($this->getRequest()->getModuleName() === 'admin' && $this->getRequest()->getControllerName() === 'page') ? 'class="active"' : '' ?>>
<a href="<?=$this->getUrl(['module' => 'admin', 'controller' => 'page', 'action' => 'index']) ?>">
<i class="fa-regular fa-file-lines hidden-sm hidden-md"></i> <?=$this->getTrans('menuSites') ?>
</a>
</li>
<?php endif; ?>
<?php if ($accesses->hasAccess('Admin', null, $accesses::TYPE_BOX)) : ?>
<?php if ($accesses && $accesses->hasAccess('Admin', null, $accesses::TYPE_BOX)) : ?>
<li <?=($this->getRequest()->getModuleName() === 'admin' && $this->getRequest()->getControllerName() === 'boxes') ? 'class="active"' : '' ?>>
<a href="<?=$this->getUrl(['module' => 'admin', 'controller' => 'boxes', 'action' => 'index']) ?>">
<i class="fa-solid fa-inbox hidden-sm hidden-md"></i> <?=$this->getTrans('menuBoxes') ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
/** @var \Ilch\View $this */

$currency = $this->escape($this->get('currency'));

/** @var \Modules\Checkoutbasic\Models\Entry[]|null $checkouts */
$checkouts = $this->get('checkout');
?>

<h1><?=$this->getTrans('bookings') ?></h1>
Expand Down Expand Up @@ -121,7 +124,7 @@ class="form-control"
</tr>
</thead>
<tbody>
<?php foreach ($this->get('checkout') as $checkout) : ?>
<?php foreach ($checkouts ?? [] as $checkout) : ?>
<?php $date = new \Ilch\Date($checkout->getDatetime()); ?>
<tr>
<td><?=$this->getEditIcon(['action' => 'treatPayment', 'id' => $this->escape($checkout->getId())]) ?></td>
Expand Down
7 changes: 5 additions & 2 deletions application/modules/checkoutbasic/views/index/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
/** @var \Ilch\View $this */

$currency = $this->escape($this->get('currency'));

/** @var \Modules\Checkoutbasic\Models\Entry[]|null $checkouts */
$checkouts = $this->get('checkout');
?>

<h1><?=$this->getTrans('accountdata') ?></h1>
Expand Down Expand Up @@ -56,14 +59,14 @@
</tr>
</thead>
<tbody>
<?php foreach ($this->get('checkout') as $checkout) : ?>
<?php foreach ($checkouts ?? [] as $checkout) : ?>
<?php $date = new \Ilch\Date($checkout->getDatetime()); ?>
<tr>
<td><?=$this->escape($date->format(null, true)) ?></td>
<td><?=$this->escape($checkout->getName()) ?></td>
<td><?=$this->escape(number_format($checkout->getAmount(), 2, '.', '')) ?> <?=$currency ?></td>
<td><?=$this->escape($checkout->getUsage()) ?></td>
</tr>
<?php endforeach; ?>
<?php endforeach; ?>
</tbody>
</table>
26 changes: 23 additions & 3 deletions application/modules/teams/config/config.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Ilch 2
* @package ilch
Expand All @@ -12,7 +13,7 @@ class Config extends \Ilch\Config\Install
{
public $config = [
'key' => 'teams',
'version' => '1.22.0',
'version' => '1.22.1',
'icon_small' => 'fa-solid fa-users',
'author' => 'Veldscholten, Kevin',
'link' => 'https://ilch.de',
Expand All @@ -37,7 +38,7 @@ public function install()

$this->db()->query('INSERT INTO `[prefix]_modules_folderrights` (`key`, `folder`) VALUES ("teams", "static/upload/image");');

$databaseConfig = new \Ilch\Config\Database($this->db());
$databaseConfig = new IlchDatabase($this->db());
$databaseConfig->set('teams_uploadpath', 'application/modules/teams/static/upload/')
->set('teams_height', '80')
->set('teams_width', '530')
Expand All @@ -49,7 +50,7 @@ public function uninstall()
$this->db()->drop('teams', true);
$this->db()->drop('teams_joins', true);

$databaseConfig = new \Ilch\Config\Database($this->db());
$databaseConfig = new IlchDatabase($this->db());
$databaseConfig->delete('teams_uploadpath')
->delete('teams_height')
->delete('teams_width')
Expand Down Expand Up @@ -167,25 +168,37 @@ public function getUpdate(string $installedVersion): string
$this->db()->query('ALTER TABLE `[prefix]_teams` MODIFY `optIn` TINYINT NOT NULL;');
// no break
case "1.1":
// no break
case "1.2":
// no break
case "1.3":
$this->db()->query('ALTER TABLE `[prefix]_teams` ADD COLUMN `optShow` TINYINT(1) NOT NULL AFTER `groupId`;');
// no break
case "1.4":
// no break
case "1.5":
// no break
case "1.6":
// no break
case "1.7":
// no break
case "1.8":
// no break
case "1.9":
// Convert tables to new character set and collate
$this->db()->query('ALTER TABLE `[prefix]_teams` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
$this->db()->query('ALTER TABLE `[prefix]_teams_joins` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
// no break
case "1.10.0":
// no break
case "1.11.0":
// no break
case "1.12.0":
// no break
case "1.13.0":
// no break
case "1.14.0":
// no break
case "1.15.0":
// Add notifyLeader column
$this->db()->query('ALTER TABLE `[prefix]_teams` ADD COLUMN `notifyLeader` TINYINT(1) NOT NULL AFTER `optIn`;');
Expand Down Expand Up @@ -213,17 +226,24 @@ public function getUpdate(string $installedVersion): string
$databaseConfig->set('teams_filetypes', implode(' ', $imageExtensions));
// no break
case "1.16.0":
// no break
case "1.17.0":
// no break
case "1.18.0":
// Update description
foreach ($this->config['languages'] as $key => $value) {
$this->db()->query(sprintf("UPDATE `[prefix]_modules_content` SET `description` = '%s' WHERE `key` = 'teams' AND `locale` = '%s';", $value['description'], $key));
}
// no break
case "1.19.0":
// no break
case "1.20.0":
// no break
case "1.21.0":
$this->db()->query("UPDATE `[prefix]_modules` SET `icon_small` = 'fa-solid fa-users' WHERE `key` = 'teams';");
// no break
case "1.22.0":
// no break
}
return 'Update function executed.';
}
Expand Down
1 change: 1 addition & 0 deletions application/modules/teams/controllers/Index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Ilch 2
* @package ilch
Expand Down
3 changes: 3 additions & 0 deletions application/modules/teams/controllers/admin/Applications.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Ilch 2
* @package ilch
Expand Down Expand Up @@ -126,6 +127,8 @@ public function acceptAction()
$email = $join->getEmail();
$team = $teamsMapper->getTeamById($join->getTeamId());
$newUser = false;
$selector = '';
$confirmedCode = '';

if ($join->getUserId()) {
$user = $userMapper->getUserById($join->getUserId());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Ilch 2
* @package ilch
Expand Down
14 changes: 14 additions & 0 deletions application/modules/teams/controllers/admin/Index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Ilch 2
* @package ilch
Expand Down Expand Up @@ -226,6 +227,19 @@ public function treatAction()
->set('userGroupList', $userGroupMapper->getGroupList());
}


public function updateAction()
{
$teamsMapper = new TeamsMapper();
if ($this->getRequest()->isSecure()) {
$teamsMapper->updateShow($this->getRequest()->getParam('id'));

$this->addMessage('saveSuccess');
}

$this->redirect(['action' => 'index']);
}

public function delAction()
{
if ($this->getRequest()->isSecure()) {
Expand Down
1 change: 1 addition & 0 deletions application/modules/teams/controllers/admin/Settings.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Ilch 2
* @package ilch
Expand Down
1 change: 1 addition & 0 deletions application/modules/teams/mappers/Joins.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Ilch 2
* @package ilch
Expand Down
37 changes: 37 additions & 0 deletions application/modules/teams/mappers/Teams.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Ilch 2
* @package ilch
Expand Down Expand Up @@ -185,6 +186,42 @@ public function sort($id, int $pos): bool
->execute();
}

/**
* @param int|TeamsModel $id
* @param int $show
* @return boolean
*/
public function updateShow($id, int $show = -1): bool
{
if ($show !== -1) {
$showNow = $show;
} else {
if (is_a($id, TeamsModel::class)) {
$show = $id->getOptShow();
} else {
$show = (int) $this->db()->select('a.optShow')
->from(['a' => $this->tablename])
->where(['a.id' => (int)$id])
->execute()
->fetchCell();
}

if ($show === 1) {
$showNow = 0;
} else {
$showNow = 1;
}
}
if (is_a($id, EntriesModel::class)) {
$id = $id->getId();
}

return $this->db()->update($this->tablename)
->values(['optShow' => $showNow])
->where(['id' => (int)$id])
->execute();
}

/**
* Inserts or updates Team Model.
*
Expand Down
1 change: 1 addition & 0 deletions application/modules/teams/models/Joins.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Ilch 2
* @package ilch
Expand Down
1 change: 1 addition & 0 deletions application/modules/teams/models/Teams.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Ilch 2
* @package ilch
Expand Down
1 change: 1 addition & 0 deletions application/modules/teams/translations/de.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Ilch 2
* @package ilch
Expand Down
1 change: 1 addition & 0 deletions application/modules/teams/translations/en.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Ilch 2
* @package ilch
Expand Down
7 changes: 4 additions & 3 deletions application/modules/teams/views/admin/applications/index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/** @var \Ilch\View $this */

/** @var \Modules\Teams\Mappers\Teams $teamsMapper */
Expand All @@ -8,7 +9,7 @@
$joins = $this->get('joins');
?>
<h1><?=$this->getTrans('manage') ?></h1>
<?php if ($joins): ?>
<?php if ($joins) : ?>
<div class="table-responsive">
<table class="table table-hover table-striped">
<colgroup>
Expand All @@ -26,7 +27,7 @@
<?php
/** @var \Modules\Teams\Models\Joins $join */
?>
<?php foreach ($joins as $join): ?>
<?php foreach ($joins as $join) : ?>
<?php $team = $teamsMapper->getTeamById($join->getTeamId()); ?>
<?php $date = new Ilch\Date($join->getDateCreated()); ?>
<tr>
Expand All @@ -38,7 +39,7 @@
</tbody>
</table>
</div>
<?php else: ?>
<?php else : ?>
<?=$this->getTrans('noApplications') ?>
<?php endif; ?>

7 changes: 4 additions & 3 deletions application/modules/teams/views/admin/applications/show.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/** @var \Ilch\View $this */

/** @var \Modules\Teams\Mappers\Joins $joinsMapper */
Expand Down Expand Up @@ -65,7 +66,7 @@
?>
</div>
</div>
<?php if ($join->getBirthday()): ?>
<?php if ($join->getBirthday()) : ?>
<div class="form-group">
<label class="col-lg-2">
<?=$this->getTrans('birthday') ?>:
Expand All @@ -75,7 +76,7 @@
</div>
</div>
<?php endif; ?>
<?php if ($join->getPlace()): ?>
<?php if ($join->getPlace()) : ?>
<div class="form-group">
<label class="col-lg-2">
<?=$this->getTrans('place') ?>:
Expand Down Expand Up @@ -120,7 +121,7 @@
<a href="<?=$this->getUrl(['action' => 'reject', 'id' => $join->getId()], null, true) ?>" class="delete_button btn btn-default">
<?=$this->getTrans('reject') ?>
</a>
<?php else: ?>
<?php else : ?>
<a href="<?=$this->getUrl(['action' => 'delete', 'id' => $join->getId()], null, true) ?>" class="delete_button btn btn-default">
<?=$this->getTrans('delete') ?>
</a>
Expand Down
Loading

0 comments on commit 286d770

Please sign in to comment.