/**
  * @param PPUser $user
  * @return array
  */
 public function getUserData(PPUser $user)
 {
     $userName = $user->getName();
     $userData = [];
     $stmt01 = $this->db->prepare("\n            SELECT userGroup, permissions\n            FROM players\n            WHERE userName = :userName;\n        ");
     $stmt01->bindValue(":userName", $userName, SQLITE3_TEXT);
     $result01 = $stmt01->execute();
     if ($result01 instanceof \SQLite3Result) {
         while ($currentRow = $result01->fetchArray(SQLITE3_ASSOC)) {
             $userData["userName"] = $userName;
             $userData["userGroup"] = $currentRow["userGroup"];
             $userData["permissions"] = explode(",", $currentRow["permissions"]);
         }
     }
     $result01->finalize();
     $stmt02 = $this->db->prepare("\n            SELECT worldName, userGroup, permissions\n            FROM players_mw\n            WHERE userName = :userName;\n        ");
     $stmt02->bindValue(":userName", $userName, SQLITE3_TEXT);
     $result02 = $stmt02->execute();
     if ($result02 instanceof \SQLite3Result) {
         while ($currentRow = $result02->fetchArray(SQLITE3_ASSOC)) {
             $worldName = $currentRow["worldName"];
             $worldPerms = explode(",", $currentRow["permissions"]);
             $userData["worlds"][$worldName]["permissions"] = $worldPerms;
         }
     }
     $result02->finalize();
     return $userData;
 }
 /**
  * @param PPUser $user
  * @return Config
  */
 public function getUserConfig(PPUser $user)
 {
     $userName = $user->getPlayer()->getName();
     if (!file_exists($this->dataFolder . strtolower($userName) . ".yml")) {
         return new Config($this->dataFolder . strtolower($userName) . ".yml", Config::YAML, array("userName" => $userName, "group" => $this->plugin->getDefaultGroup()->getName(), "permissions" => array(), "worlds" => array()));
     } else {
         return new Config($this->dataFolder . strtolower($userName) . ".yml", Config::YAML, array());
     }
 }
Example #3
0
 /**
  * @param PPUser $user
  * @return array
  */
 public function getUserData(PPUser $user)
 {
     $userName = $user->getName();
     $userData = [];
     $result01 = $this->db->query("\n            SELECT userGroup, permissions\n            FROM players\n            WHERE userName = {$userName};\n        ");
     if ($result01 instanceof \mysqli_result) {
         while ($currentRow = $result01->fetch_array(MYSQLI_ASSOC)) {
             $userData["userName"] = $userName;
             $userData["userGroup"] = $currentRow["userGroup"];
             $userData["permissions"] = explode(",", $currentRow["permissions"]);
         }
     }
     $result01->free();
     $result02 = $this->db->query("\n            SELECT worldName, userGroup, permissions\n            FROM players_mw\n            WHERE userName = {$userName};\n        ");
     if ($result02 instanceof \mysqli_result) {
         while ($currentRow = $result02->fetch_array(MYSQLI_ASSOC)) {
             $worldName = $currentRow["worldName"];
             $worldPerms = explode(",", $currentRow["permissions"]);
             $userData["worlds"][$worldName]["permissions"] = $worldPerms;
         }
     }
     $result02->free();
     return $userData;
 }
Example #4
0
 /**
  * @param PPUser $user
  * @param null $levelName
  * @return PPGroup|null
  */
 public function getUserGroup(PPUser $user, $levelName = null)
 {
     return $user->getGroup($levelName);
 }
Example #5
0
 /**
  * @param PPUser $user
  * @param array $tempUserData
  */
 public function setUserData(PPUser $user, array $tempUserData)
 {
     $userName = $user->getName();
     $userGroup = $this->plugin->getDefaultGroup()->getName();
     $permissions = "";
     if (isset($tempUserData["userName"])) {
         $userName = $tempUserData["userName"];
     }
     if (isset($tempUserData["group"])) {
         $userGroup = $tempUserData["group"];
     }
     if (isset($tempUserData["permissions"])) {
         $permissions = implode(",", $tempUserData["permissions"]);
     }
     $stmt01 = $this->db->prepare("\n            INSERT OR REPLACE INTO players (userName, userGroup, permissions)\n            VALUES (:userName, :userGroup, :permissions);\n        ");
     $stmt01->bindValue(":userName", $userName, SQLITE3_TEXT);
     $stmt01->bindValue(":userGroup", $userGroup, SQLITE3_TEXT);
     $stmt01->bindValue(":permissions", $permissions, SQLITE3_TEXT);
     $result01 = $stmt01->execute();
     $result01->finalize();
     if (isset($tempUserData["worlds"])) {
         $stmt02 = $this->db->prepare("\n                INSERT OR REPLACE INTO players_mw (userName, worldName, userGroup, permissions)\n                VALUES (:userName, :worldName, :userGroup, :permissions);\n            ");
         foreach ($tempUserData["worlds"] as $worldName => $worldData) {
             $worldGroup = $this->plugin->getDefaultGroup()->getName();
             $worldPerms = "";
             if (isset($worldData["userGroup"])) {
                 $worldGroup = $worldData["userGroup"];
             }
             if (isset($worldData["permissions"])) {
                 $worldPerms = $worldData["permissions"];
             }
             $stmt02->bindValue(":userName", $userName, SQLITE3_TEXT);
             $stmt02->bindValue(":worldName", $worldName, SQLITE3_TEXT);
             $stmt02->bindValue(":userGroup", $worldGroup, SQLITE3_TEXT);
             $stmt02->bindValue(":permissions", $worldPerms, SQLITE3_TEXT);
             $result02 = $stmt02->execute();
             $result02->finalize();
         }
     }
 }