57 lines
1.7 KiB
PHP
Executable File
57 lines
1.7 KiB
PHP
Executable File
<?php #lnk/xx_personal_gruppen/class.php
|
|
|
|
class Personal_GruppenLink extends BaseLink
|
|
{
|
|
public function __construct($database, $keyvaluestore, $manager, $info, $page) {
|
|
parent::__construct($database, $keyvaluestore, $manager, $info, $page);
|
|
}
|
|
|
|
protected function insert($ids) {
|
|
if ($ids["Gruppen"]==null || $ids["Personal"]==null) {
|
|
return 400;
|
|
}
|
|
if (!$this->man->user->HasRight($this->adminRight)) {
|
|
return 403; // You shall not pass!
|
|
}
|
|
|
|
$qry = "INSERT INTO Personal_Gruppen (Personal, Gruppen) VALUES (?, ?)";
|
|
if ($stmt = $this->db->prepare($qry)) {
|
|
$stmt->bind_param("ii", $ids["Personal"], $ids["Gruppen"]);
|
|
$stmt->execute();
|
|
if (1==$stmt->affected_rows) {
|
|
$this->man->AddMessage("Personal zu Gruppe hinzugefügt!");
|
|
return 201;
|
|
} else {
|
|
return 200;
|
|
}
|
|
} else {
|
|
$this->man->AddMessage("Mysql error: ".$this->db->error);
|
|
}
|
|
return 500; // Should not reach this stage
|
|
}
|
|
|
|
protected function remove($ids) {
|
|
if ($ids["Gruppen"]==null || $ids["Personal"]==null) {
|
|
return 400;
|
|
}
|
|
if (!$this->man->user->HasRight($this->adminRight)) {
|
|
return 403; // You shall not pass!
|
|
}
|
|
|
|
$qry = "DELETE FROM Personal_Gruppen WHERE Personal = ? AND Gruppen = ?";
|
|
if ($stmt = $this->db->prepare($qry)) {
|
|
$stmt->bind_param("ii", $ids["Personal"], $ids["Gruppen"]);
|
|
$stmt->execute();
|
|
if (1==$stmt->affected_rows) {
|
|
$this->man->AddMessage("Personal aus Gruppe entfernt!");
|
|
return 200;
|
|
} else {
|
|
return 404;
|
|
}
|
|
} else {
|
|
$this->man->AddMessage("Mysql error: ".$this->db->error);
|
|
return 500;
|
|
}
|
|
}
|
|
}
|