コード例 #1
0
 /**
  * Updates the moderator form.
  *
  * @param string $username
  * @param string $usertitle
  * @param string $email
  * @param int $delete
  * @param int $umode
  * @param string $activation
  * @param string $ipcheck
  * @param int $usergroupid
  * @param int $points
  * @param int $fpoints
  * @param int $dpoints
  * @param int $rpoints
  * @param string $password
  * @param int $languageid
  * @param string $templatepackage
  * @param string $theme
  * @param string $js_interface
  * @return Bengine_Game_Controller_Moderator
  */
 protected function updateUser($username, $usertitle, $email, $delete, $umode, $activation, $ipcheck, $usergroupid, $points, $fpoints, $dpoints, $rpoints, $password, $languageid, $templatepackage, $theme, $js_interface)
 {
     $select = array("userid", "username", "email");
     $result = Core::getQuery()->select("user", $select, "", Core::getDB()->quoteInto("userid = ?", $this->userid));
     if ($row = $result->fetchRow()) {
         $result->closeCursor();
         Hook::event("SaveUserModeration", array(&$row));
         $delete = $delete == 1 ? 1 : 0;
         $umode = $umode == 1 ? 1 : 0;
         $activation = $activation == 1 ? "" : "1";
         $ipcheck = $ipcheck == 1 ? 1 : 0;
         $username = trim($username);
         $usertitle = trim($usertitle);
         $js_interface = trim($js_interface);
         if (Core::getUser()->ifPermissions("CAN_EDIT_USER")) {
             Core::getQuery()->delete("user2group", "userid = ?", null, null, array($this->userid));
             Core::getQuery()->insert("user2group", array("usergroupid" => $usergroupid, "userid" => $this->userid));
             Core::getQuery()->update("user", array("points" => floatval($points), "fpoints" => (int) $fpoints, "dpoints" => (int) $dpoints, "rpoints" => (int) $rpoints), "userid = ?", array($this->userid));
         }
         if ($umode) {
             setProdOfUser($this->userid, 0);
         }
         if (!Str::compare($username, $row["username"])) {
             $num = Core::getQuery()->select("user", "userid", "", Core::getDB()->quoteInto("username = ?", $username))->rowCount();
             if ($num > 0) {
                 $username = $row["username"];
             }
         }
         if (!Str::compare($email, $row["email"])) {
             $num = Core::getQuery()->select("user", "userid", "", Core::getDB()->quoteInto("email = ?", $email))->rowCount();
             if ($num > 0) {
                 $email = $row["email"];
             }
         }
         if (Str::length($password) > Core::getOptions()->get("MIN_PASSWORD_LENGTH")) {
             $encryption = Core::getOptions("USE_PASSWORD_SALT") ? "md5_salt" : "md5";
             $password = Str::encode($password, $encryption);
             Core::getQuery()->update("password", array("password" => $password, "time" => TIME), "userid = ?", array($this->userid));
         }
         $spec = array("username" => $username, "usertitle" => $usertitle, "email" => $email, "delete" => $delete, "umode" => $umode, "activation" => $activation, "languageid" => $languageid, "ipcheck" => $ipcheck, "templatepackage" => $templatepackage, "theme" => $theme, "js_interface" => $js_interface);
         Core::getQuery()->update("user", $spec, "userid = ?", array($this->userid));
     }
     return $this;
 }
コード例 #2
0
 /**
  * Disables the vacation mode and starts the resource production.
  *
  * @return Bengine_Game_Controller_Preferences
  */
 protected function disableUmode()
 {
     setProdOfUser(Core::getUser()->get("userid"), 100);
     Core::getQuery()->update("user", array("umode" => 0), "userid = ?", array(Core::getUser()->get("userid")));
     Core::getQuery()->update("planet", array("last" => TIME), "userid = ? AND planetid != ?", array(Core::getUser()->get("userid"), Core::getUser()->get("curplanet")));
     Core::getUser()->rebuild();
     Hook::event("DisableVacationMode");
     Logger::dieMessage("UMODE_DISABLED", "info");
     return $this;
 }