public function copyUserRestrictions($fromUserId) { $mUD = new mUserdata(); $mUD->addAssocV3("UserID", "=", $fromUserId); $mUD->lCV3(); $cUD = new mUserdata(); $cUD->addAssocV3("UserID", "=", $this->ID); $cUD->addAssocV3("typ", "=", "uRest", "AND", "1"); $cUD->addAssocV3("typ", "=", "relab", "OR", "1"); $cUD->addAssocV3("typ", "=", "hideF", "OR", "1"); $cUD->addAssocV3("typ", "=", "pSpec", "OR", "1"); $cUD->addAssocV3("typ", "=", "pHide", "OR", "1"); $cUD->lCV3(); if ($cUD->getNextEntry() != null) { die("Target userdata not empty!"); } while ($t = $mUD->getNextEntry()) { $A = $t->getA(); $A->UserID = $this->ID; $nU = new Userdata(-1); $nU->setA($A); $nU->newMe(); } }
public function setUserdata($name, $wert, $typ = "", $UserID = 0, $echoSaved = false) { if ($UserID != 0 and $_SESSION["S"]->isUserAdmin() == "0") { echo "Only an admin-user can change Userdata of other users!"; exit; } if ($typ == "uRest" and $_SESSION["S"]->isUserAdmin() == "0") { echo "Only an admin-user can change restrictions!"; exit; } if ($UserID == 0) { $UserID = $_SESSION["S"]->getCurrentUser()->getID(); } $UD = $this->getUserdata($name, $UserID); if ($UD == null) { $nUD = new Userdata(-1); $nUDA = $nUD->newAttributes(); $nUDA->UserID = $UserID; $nUDA->name = $name; $nUDA->wert = $wert; $nUDA->typ = $typ; $nUD->setA($nUDA); $nUD->newMe(); $this->collector[] = $nUD; } else { $UD->saveNewValue($wert); } if ($echoSaved) { Red::messageSaved(); } }