Applied fixes from StyleCI
This commit is contained in:
parent
93d66e51fe
commit
218e78a309
3 changed files with 36 additions and 35 deletions
|
@ -191,31 +191,31 @@ class User
|
||||||
return $times;
|
return $times;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the main rank of this user
|
// Set the main rank of this user
|
||||||
public function setMainRank($rank)
|
public function setMainRank($rank)
|
||||||
{
|
{
|
||||||
// Only allow this if this rank is actually present in their set of ranks
|
// Only allow this if this rank is actually present in their set of ranks
|
||||||
if (!in_array($rank, $this->ranks())) {
|
if (!in_array($rank, $this->ranks())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it does exist update their row
|
// If it does exist update their row
|
||||||
Database::update('user', [
|
Database::update('user', [
|
||||||
[
|
[
|
||||||
'rank_main' => $rank,
|
'rank_main' => $rank,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'user_id' => [$this->id(), '='],
|
'user_id' => [$this->id(), '='],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Return true if everything was successful
|
// Return true if everything was successful
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if this user has the specified ranks
|
// Check if this user has the specified ranks
|
||||||
public function hasRanks($ranks)
|
public function hasRanks($ranks)
|
||||||
{
|
{
|
||||||
// Check if the main rank is the specified rank
|
// Check if the main rank is the specified rank
|
||||||
if (in_array($this->mainRank->id(), $ranks)) {
|
if (in_array($this->mainRank->id(), $ranks)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -231,12 +231,12 @@ class User
|
||||||
|
|
||||||
// If all fails return false
|
// If all fails return false
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For compatibility, too lazy to update the references right now!
|
// For compatibility, too lazy to update the references right now!
|
||||||
public function checkIfUserHasRanks($ranks)
|
public function checkIfUserHasRanks($ranks)
|
||||||
{
|
{
|
||||||
return $this->hasRanks($ranks);
|
return $this->hasRanks($ranks);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a new friend
|
// Add a new friend
|
||||||
|
@ -721,16 +721,17 @@ class User
|
||||||
return [1, 'SUCCESS'];
|
return [1, 'SUCCESS'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update a user's userData
|
// Update a user's userData
|
||||||
public function setUserData($data) {
|
public function setUserData($data)
|
||||||
// Merge the arrays
|
{
|
||||||
$data = array_merge($this->userData(), $data);
|
// Merge the arrays
|
||||||
|
$data = array_merge($this->userData(), $data);
|
||||||
|
|
||||||
// Encode it
|
// Encode it
|
||||||
$data = json_encode($data);
|
$data = json_encode($data);
|
||||||
|
|
||||||
// Save it in the database
|
// Save it in the database
|
||||||
Database::update('users', [
|
Database::update('users', [
|
||||||
[
|
[
|
||||||
'user_data' => $data,
|
'user_data' => $data,
|
||||||
],
|
],
|
||||||
|
@ -738,5 +739,5 @@ class User
|
||||||
'user_id' => [$this->id(), '='],
|
'user_id' => [$this->id(), '='],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -710,7 +710,7 @@ class Users
|
||||||
// Get the specified user
|
// Get the specified user
|
||||||
$user = new User($uid);
|
$user = new User($uid);
|
||||||
|
|
||||||
$current = $user->ranks();
|
$current = $user->ranks();
|
||||||
|
|
||||||
// Check the current ranks for ranks in the set array
|
// Check the current ranks for ranks in the set array
|
||||||
foreach ($current as $key => $rank) {
|
foreach ($current as $key => $rank) {
|
||||||
|
|
|
@ -939,7 +939,7 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification
|
||||||
$userPage = base64_encode($_POST['userpage']);
|
$userPage = base64_encode($_POST['userpage']);
|
||||||
|
|
||||||
// Update database
|
// Update database
|
||||||
$currentUser->setUserData(['userPage' => $userPage]);
|
$currentUser->setUserData(['userPage' => $userPage]);
|
||||||
|
|
||||||
// Set render data
|
// Set render data
|
||||||
$renderData['page'] = [
|
$renderData['page'] = [
|
||||||
|
@ -957,7 +957,7 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification
|
||||||
$signature = base64_encode($_POST['signature']);
|
$signature = base64_encode($_POST['signature']);
|
||||||
|
|
||||||
// Update database
|
// Update database
|
||||||
$currentUser->setUserData(['signature' => $signature]);
|
$currentUser->setUserData(['signature' => $signature]);
|
||||||
|
|
||||||
// Set render data
|
// Set render data
|
||||||
$renderData['page'] = [
|
$renderData['page'] = [
|
||||||
|
|
Reference in a new issue