Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • foodsharing-dev/foodsharing
  • alpha-chicken/foodsharing
  • depate/foodsharing
  • dthulke/foodsharing
  • corbolais/foodsharing
  • jentsch.michael/foodsharing
  • abejaranoh/foodsharing
  • WUUUGI/foodsharing
  • JonasBoewer/foodsharing
  • pauleweb/foodsharing
  • sp00p/foodsharing
  • dahse89/foodsharing
  • UFHH01/foodsharing
  • fgulbakir/foodsharing
  • katleesi/foodsharing
  • scfount/foodsharing
  • Laura.cyprian/foodsharing
  • ulrike.f/foodsharing
  • Krunchjo/foodsharing
  • CHECKJonas/foodsharing
  • tinuthir/foodsharing
  • lizhengdao/foodsharing
  • KatharinaMoel/foodsharing
  • stepin/foodsharing
  • weblate/foodsharing
  • teresaher2/foodsharing
  • blinry/foodsharing
  • maktooob/foodsharing
  • armbiant/gnome-go-foodsharing
  • tobiaskohlbau/foodsharing
  • Buntelrus/foodsharing
  • vitorzago/foodsharing
  • kingu/foodsharing
  • tutNichts/foodsharing
  • yvonnecholewik/foodsharing
  • Nudin/foodsharing
  • FreyJo/foodsharing
  • BlackScorp/foodsharing
  • viveknshah/foodsharing
  • FlorianMaak/foodsharing
  • poorandweird/foodsharing
  • Friedrich-B/foodsharing
  • viper-kun/foodsharing
  • schanso/foodsharing
  • ThussiJ/foodsharing
  • newphonenewlife66/foodsharing
  • trippincode/foodsharing-fork
  • superernie77/foodsharing
  • zaurask/foodsharing
  • DiDoHH/foodsharing
  • powerdan/foodsharing
  • nmiddelmann/foodsharing
  • c-h-i-c-k-e-n/foodsharing
  • EvrenAlp/foodsharing
  • Nika-Mel/foodsharing
  • robinkernel/foodsharing
  • andre161292/foodsharing
  • castn/foodsharing
  • skurka/foodsharing
  • xboutaj/foodsharing
  • armbian33/gnome-rust-foodsharing
61 results
Select Git revision
Show changes
Commits on Source (4)
......@@ -17,6 +17,9 @@
- removed copy of email sending method for CLI applications !464 @NerdyProjects
- refactored statistics from model to gateway !476 #9 @peter.toennies
- removed several layers of the legacy database-classes structure !477 @peter.toennies
- refactored content from model to gateway !481 #9 @peter.toennies
- refactored NewArea module from model to gateway !483 #9 @peter.toennies
- refactored NewArea module from model to gateway !484 #9 @peter.toennies
## Dev/Test/CI stuff
......
......@@ -3,3 +3,10 @@ import '@/globals'
import './Content.css'
import '@/tablesorter'
import 'jquery.tinymce'
import { expose } from '@/utils'
import { ifconfirm } from '@/script'
expose({
ifconfirm
})
\ No newline at end of file
......@@ -10,11 +10,9 @@ class ContentControl extends Control
private $contentGateway;
public function __construct(
ContentModel $model,
ContentView $view,
ContentGateway $contentGateway
) {
$this->model = $model;
$this->view = $view;
$this->contentGateway = $contentGateway;
......@@ -41,7 +39,7 @@ class ContentControl extends Control
$this->func->pageLink('content', 'back_to_overview')
)), $this->func->s('actions')), CNT_RIGHT);
} elseif ($id = $this->func->getActionId('delete')) {
if ($this->model->del_content($id)) {
if ($this->contentGateway->delete($id)) {
$this->func->info($this->func->s('content_deleted'));
$this->func->goPage();
}
......@@ -189,7 +187,7 @@ class ContentControl extends Control
}
}
public function faq()
public function faq(): void
{
$this->func->addBread('F.A.Q');
$this->func->addTitle('F.A.Q.');
......@@ -203,7 +201,7 @@ class ContentControl extends Control
$cat_ids[] = 5;
}
if ($faq = $this->model->listFaq($cat_ids)) {
if ($faq = $this->contentGateway->listFaq($cat_ids)) {
$this->func->addContent($this->view->faq($faq));
}
}
......
......@@ -6,7 +6,7 @@ use Foodsharing\Modules\Core\BaseGateway;
class ContentGateway extends BaseGateway
{
public function get($id)
public function get($id): array
{
return $this->db->fetch('
SELECT `title`, `body`
......@@ -16,7 +16,7 @@ class ContentGateway extends BaseGateway
);
}
public function list()
public function list(): array
{
return $this->db->fetchAll('
SELECT `id`,
......@@ -26,7 +26,7 @@ class ContentGateway extends BaseGateway
);
}
public function getDetail($id)
public function getDetail($id): array
{
return $this->db->fetch('
SELECT
......@@ -43,7 +43,7 @@ class ContentGateway extends BaseGateway
);
}
public function create($data)
public function create($data): int
{
return $this->db->insert('fs_content', [
'name' => strip_tags($data['name']),
......@@ -53,7 +53,7 @@ class ContentGateway extends BaseGateway
]);
}
public function update($id, $data)
public function update($id, $data): int
{
return $this->db->update('fs_content', [
'name' => strip_tags($data['name']),
......@@ -62,4 +62,27 @@ class ContentGateway extends BaseGateway
'last_mod' => $data['last_mod']
], ['id' => $id]);
}
public function delete($id): int
{
return $this->db->delete('fs_content', ['id' => $id]);
}
public function listFaq($cat_ids): array
{
$stm = '
SELECT
`id`,
`name`,
`answer`
FROM
fs_faq
WHERE
`faq_kategorie_id` IN(' . implode(',', $cat_ids) . ')
';
return $this->db->fetchAll($stm);
}
}
<?php
namespace Foodsharing\Modules\Content;
use Foodsharing\Lib\Db\Db;
class ContentModel extends Db
{
public function listFaq($cat_ids)
{
return $this->q('
SELECT
`id`,
`name`,
`answer`
FROM
fs_faq
WHERE
`faq_kategorie_id` IN(' . implode(',', $cat_ids) . ')
');
}
}
......@@ -6,9 +6,11 @@ use Foodsharing\Modules\Core\Control;
class NewAreaControl extends Control
{
public function __construct(NewAreaModel $model, NewAreaView $view)
private $newAreaGateway;
public function __construct(NewAreaGateway $newAreaGateway, NewAreaView $view)
{
$this->model = $model;
$this->newAreaGateway = $newAreaGateway;
$this->view = $view;
parent::__construct();
......@@ -21,7 +23,7 @@ class NewAreaControl extends Control
public function index()
{
$this->func->addBread('Anfragen für neue Bezirke');
if ($foodsaver = $this->model->getWantNews()) {
if ($foodsaver = $this->newAreaGateway->listWantNews()) {
$this->func->addContent($this->view->listWantNews($foodsaver));
$this->func->addContent($this->view->orderToBezirk(), CNT_RIGHT);
......
......@@ -2,14 +2,13 @@
namespace Foodsharing\Modules\NewArea;
use Foodsharing\Lib\Db\Db;
use Foodsharing\Modules\Core\BaseGateway;
class NewAreaModel extends Db
class NewAreaGateway extends BaseGateway
{
public function getWantNews()
public function listWantNews(): array
{
$fs = $this->q('
$stm = '
SELECT `id`,
`name`,
`nachname`,
......@@ -21,30 +20,27 @@ class NewAreaModel extends Db
`want_new`
FROM `fs_foodsaver`
WHERE `want_new` = 1
');
';
$fs = $this->db->fetchAll($stm);
foreach ($fs as $key => $f) {
$fs[$key]['bezirke'] = $this->q('
$stm = '
SELECT b.`name`,
b.`id`
FROM `fs_foodsaver_has_bezirk` bh,
`fs_bezirk` b
WHERE bh.bezirk_id = b.id
AND bh.foodsaver_id = ' . $f['id'] . '
');
AND bh.foodsaver_id = :fs_id
';
$fs[$key]['bezirke'] = $this->db->fetchAll($stm, [':fs_id' => $f['id']]);
}
return $fs;
}
public function clearWantNew($fsid)
public function clearWantNew($fsId): void
{
$this->update('
UPDATE `fs_foodsaver`
SET `want_new` = 0,
`new_bezirk` = ""
WHERE `id` = ' . (int)$fsid . '
');
$this->db->update('fs_foodsaver', ['want_new' => 0, 'new_bezirk' => ''], ['id' => (int)$fsId]);
}
}
......@@ -2,16 +2,19 @@
namespace Foodsharing\Modules\NewArea;
use Foodsharing\Lib\Db\Db;
use Foodsharing\Modules\Core\Control;
use Foodsharing\Modules\Region\RegionGateway;
class NewAreaXhr extends Control
{
private $regionGateway;
private $newAreaGateway;
public function __construct(NewAreaModel $model, NewAreaView $view, RegionGateway $regionGateway)
public function __construct(Db $model, NewAreaGateway $newAreaGateway, NewAreaView $view, RegionGateway $regionGateway)
{
$this->model = $model;
$this->newAreaGateway = $newAreaGateway;
$this->view = $view;
$this->regionGateway = $regionGateway;
......@@ -45,7 +48,7 @@ class NewAreaXhr extends Control
$message = str_replace(array('{ANREDE}', '{NAME}'), array($anrede, $name), $_GET['msg']);
$this->func->libmail(false, $foodsaver['email'], $_GET['subject'], $message);
$this->model->clearWantNew($fid);
$this->newAreaGateway->clearWantNew($fid);
$js .= '$(".wantnewcheck[value=\'' . $fid . '\']").parent().parent().remove();';
}
......@@ -66,7 +69,7 @@ class NewAreaXhr extends Control
$parts = explode('-', $_GET['del']);
if (count($parts) > 0) {
foreach ($parts as $p) {
$this->model->clearWantNew($p);
$this->newAreaGateway->clearWantNew($p);
}
}
......