36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Subroutes;
|
|
|
|
require_once("links/Personal_Gruppen.php");
|
|
|
|
trait Personal_Gruppen
|
|
{
|
|
protected function answer_Personal_Gruppen($pid, $gid) {return $this->personal_gruppen_answer($pid, $gid);} // called from Personal
|
|
protected function answer_Gruppen_Personal($gid, $pid) {return $this->personal_gruppen_answer($pid, $gid);} // called from Gruppen
|
|
|
|
protected function personal_gruppen_answer($leftid, $rightid) {
|
|
switch (\Request::Method()) {
|
|
case "POST":
|
|
if ($this->personal_gruppen_can("set", $leftid, $rightid) && \Links\Personal_Gruppen::Get()->Set($leftid, $rightid)) {
|
|
\Response::Get()->SubInserted();
|
|
return true;
|
|
}
|
|
break;
|
|
case "DELETE":
|
|
if ($this->personal_gruppen_can("unset", $leftid, $rightid) && \Links\Personal_Gruppen::Get()->Unset($leftid, $rightid)) {
|
|
\Response::Get()->SubDeleted();
|
|
return true;
|
|
}
|
|
break;
|
|
default:
|
|
\Response::Get()->NotImplemented();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
protected function personal_gruppen_can($action, $leftid, $rightid) {
|
|
return !is_null($leftid) && !is_null($rightid);
|
|
}
|
|
}
|