57 lines
1.7 KiB
PHP
57 lines
1.7 KiB
PHP
<?php #lnk/xx_personal_abteilungen/class.php
|
|
|
|
class Personal_AbteilungenLink extends BaseLink
|
|
{
|
|
public function __construct($database, $keyvaluestore, $manager, $info, $page) {
|
|
parent::__construct($database, $keyvaluestore, $manager, $info, $page);
|
|
}
|
|
|
|
protected function insert($ids) {
|
|
if ($ids["Abteilungen"]==null || $ids["Personal"]==null) {
|
|
return 400;
|
|
}
|
|
if (!$this->man->user->HasRight($this->adminRight)) {
|
|
return 403; // You shall not pass!
|
|
}
|
|
|
|
$qry = "INSERT INTO Personal_Abteilungen (Personal, Abteilungen) VALUES (?, ?)";
|
|
if ($stmt = $this->db->prepare($qry)) {
|
|
$stmt->bind_param("ii", $ids["Personal"], $ids["Abteilungen"]);
|
|
$stmt->execute();
|
|
if (1==$stmt->affected_rows) {
|
|
$this->man->AddMessage("Personal zu Abteilung 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["Abteilungen"]==null || $ids["Personal"]==null) {
|
|
return 400;
|
|
}
|
|
if (!$this->man->user->HasRight($this->adminRight)) {
|
|
return 403; // You shall not pass!
|
|
}
|
|
|
|
$qry = "DELETE FROM Personal_Abteilungen WHERE Abteilungen = ? AND Personal = ?";
|
|
if ($stmt = $this->db->prepare($qry)) {
|
|
$stmt->bind_param("ii", $ids["Abteilungen"], $ids["Personal"]);
|
|
$stmt->execute();
|
|
if (1==$stmt->affected_rows) {
|
|
$this->man->AddMessage("Personal aus Abteilung entfernt!");
|
|
return 200;
|
|
} else {
|
|
return 404;
|
|
}
|
|
} else {
|
|
$this->man->AddMessage("Mysql error: ".$this->db->error);
|
|
return 500;
|
|
}
|
|
}
|
|
}
|