public function insertRolle()
 {
     if (!UserRolle::doesExists($this->request->user, $this->request->ro_id)) {
         $this->userRolle = new UserRolle();
         $this->userRolle->ur_user = $this->request->user;
         $this->userRolle->ur_rolle = $this->request->ro_id;
         $this->userRolle->save();
     }
 }
 /**
  * @param int $user
  * @param int|string $rolle
  */
 public static function zuordnen($user, $rolle)
 {
     if (is_string($rolle)) {
         $rollenObj = Rolle::loadBySchluessel($rolle);
         $rolle = $rollenObj->id;
     }
     if (!static::doesExists($user, $rolle)) {
         $temp = new UserRolle();
         $temp->ur_user = $user;
         $temp->ur_rolle = $rolle;
         $temp->save();
     }
 }
 public function install()
 {
     parent::install();
     $administratoren = new Rolle();
     $administratoren->ro_bezeichnung = 'Administratoren';
     $administratoren->ro_aktiv = true;
     $administratoren->ro_parent = 0;
     $administratoren->ro_neuebenutzer = false;
     $administratoren->save();
     $besucher = new Rolle();
     $besucher->ro_bezeichnung = 'Besucher';
     $besucher->ro_aktiv = true;
     $besucher->ro_parent = 0;
     $besucher->ro_neuebenutzer = true;
     $besucher->save();
     $admin = new User();
     $admin->us_benutzername = 'admin';
     $admin->us_passwort = 'masterkey';
     $admin->us_aktiv = 1;
     $admin->us_vorname = 'Administrator';
     $admin->us_anonymous = false;
     $admin->us_sprache = 1;
     $admin->save();
     $anonymous = new User();
     $anonymous->us_benutzername = mt_rand(1000000, 9999999);
     $anonymous->us_passwort = mt_rand(1000000, 9999999);
     $anonymous->us_aktiv = 1;
     $anonymous->us_vorname = 'Anonymous';
     $anonymous->us_anonymous = true;
     $anonymous->us_sprache = 1;
     $anonymous->save();
     $rolle = new UserRolle();
     $rolle->ur_user = $admin->id;
     $rolle->ur_rolle = $administratoren->id;
     $rolle->save();
     $rolle = new UserRolle();
     $rolle->ur_user = $anonymous->id;
     $rolle->ur_rolle = $besucher->id;
     $rolle->save();
 }