diff --git a/front/views/Home.tsx b/front/views/Home.tsx
index 6f22f01..132457c 100644
--- a/front/views/Home.tsx
+++ b/front/views/Home.tsx
@@ -29,7 +29,6 @@ export default function Home({
teams: Team[]
username: string
}) {
- console.log(allTactics)
return (
diff --git a/src/App/Controller/TacticController.php b/src/App/Controller/TacticController.php
index f2ee6a1..5be9d03 100644
--- a/src/App/Controller/TacticController.php
+++ b/src/App/Controller/TacticController.php
@@ -65,4 +65,16 @@ class TacticController
$this->teams->unshareTactic($tacticId);
return ViewHttpResponse::redirect("/");
}
+
+ public function unshareTacticToTeam(int $tacticId, int $teamId, SessionHandle $session) : HttpResponse
+ {
+ $this->teams->unshareTacticToTeam($tacticId, $teamId);
+ return ViewHttpResponse::redirect("/");
+ }
+
+ public function unshareTacticToAccount(int $tacticId, int $accountId, SessionHandle $session) : HttpResponse
+ {
+ $this->tactics->unshareTacticToAccount($tacticId, $accountId);
+ return ViewHttpResponse::redirect("/");
+ }
}
diff --git a/src/App/Controller/UserController.php b/src/App/Controller/UserController.php
index 308a525..8dd7c31 100644
--- a/src/App/Controller/UserController.php
+++ b/src/App/Controller/UserController.php
@@ -36,20 +36,17 @@ class UserController {
$allTactics = $this->tactics->getAll($user->getId());
$name = $user->getName();
- if ($this->teams != null) {
- $teams = $this->teams->getAll($user->getId());
-
- $allTacticsShared = $this->tactics->getAllTacticShared($user->getId());
- if(isset($allTacticsShared)) {
- foreach ($allTacticsShared as $tactic) {
- if(!in_array($tactic, $allTactics)) {
- array_push($allTactics, $tactic);
- }
+ $allTacticsShared = $this->tactics->getAllTacticShared($user->getId());
+ if(isset($allTacticsShared)) {
+ foreach ($allTacticsShared as $tactic) {
+ if(!in_array($tactic, $allTactics)) {
+ array_push($allTactics, $tactic);
}
}
+ }
- var_dump($allTactics);
- var_dump($teams);
+ if ($this->teams != null) {
+ $teams = $this->teams->getAll($user->getId());
} else {
$teams = [];
}
diff --git a/src/Core/Data/TacticInfo.php b/src/Core/Data/TacticInfo.php
index c3b8667..437af15 100644
--- a/src/Core/Data/TacticInfo.php
+++ b/src/Core/Data/TacticInfo.php
@@ -2,7 +2,7 @@
namespace IQBall\Core\Data;
-class TacticInfo {
+class TacticInfo implements \JsonSerializable {
private int $id;
private string $name;
private int $creationDate;
@@ -59,4 +59,9 @@ class TacticInfo {
public function getCreationDate(): int {
return $this->creationDate;
}
+
+ public function jsonSerialize()
+ {
+ return get_object_vars($this);
+ }
}
diff --git a/src/Core/Gateway/AccountGateway.php b/src/Core/Gateway/AccountGateway.php
index fa098e7..f19158e 100644
--- a/src/Core/Gateway/AccountGateway.php
+++ b/src/Core/Gateway/AccountGateway.php
@@ -113,4 +113,16 @@ class AccountGateway {
return intval($this->con->lastInsertId());
}
+ public function unshareTacticToAccount(int $tacticId, int $accountId): int {
+ $this->con->exec(
+ "DELETE FROM TacticSharedAccount WHERE id_tactic = :tacticId AND id_account = :accountId",
+ [
+ ":tacticId" => [$tacticId, PDO::PARAM_INT],
+ ":accountId" => [$accountId, PDO::PARAM_INT],
+ ]
+ );
+ return intval($this->con->lastInsertId());
+ }
+
+
}
diff --git a/src/Core/Gateway/TeamGateway.php b/src/Core/Gateway/TeamGateway.php
index 46bcfbb..f11c389 100644
--- a/src/Core/Gateway/TeamGateway.php
+++ b/src/Core/Gateway/TeamGateway.php
@@ -54,6 +54,16 @@ class TeamGateway {
return intval($this->con->lastInsertId());
}
+ public function unshareTacticToTeam(int $tacticId, int $teamId): int {
+ $this->con->exec(
+ "DELETE FROM TacticSharedTeam WHERE id_tactic = :tacticId AND id_team = :teamId",
+ [
+ ":tacticId" => [$tacticId, PDO::PARAM_INT],
+ ":teamId" => [$teamId, PDO::PARAM_INT],
+ ]
+ );
+ return intval($this->con->lastInsertId());
+ }
/**
diff --git a/src/Core/Model/TacticModel.php b/src/Core/Model/TacticModel.php
index d02486c..1669dfc 100644
--- a/src/Core/Model/TacticModel.php
+++ b/src/Core/Model/TacticModel.php
@@ -188,4 +188,9 @@ class TacticModel {
{
return $this->users->unshareTactic($tacticId);
}
+
+ public function unshareTacticToAccount(int $tacticId, int $accountId): int
+ {
+ return $this->users->unshareTacticToAccount($tacticId, $accountId);
+ }
}
diff --git a/src/Core/Model/TeamModel.php b/src/Core/Model/TeamModel.php
index 4373a45..4abc10a 100644
--- a/src/Core/Model/TeamModel.php
+++ b/src/Core/Model/TeamModel.php
@@ -88,6 +88,9 @@ class TeamModel {
return $this->teams->unshareTactic($tacticId);
}
+ public function unshareTacticToTeam(int $tacticId, int $teamId): int {
+ return $this->teams->unshareTacticToTeam($tacticId, $teamId);
+ }
/**
* delete a member from given team identifier