Skip to content
Browse files

Edited API/Actions/examples/UserEdit.php via GitHub

  • Loading branch information...
1 parent 2cd8ab6 commit 928fd24c797c1d0ba8bad94cf64cba0d3c5f56b5 @evantahler committed May 9, 2011
Showing with 19 additions and 26 deletions.
  1. +19 −26 API/Actions/examples/UserEdit.php
View
45 API/Actions/examples/UserEdit.php
@@ -28,41 +28,34 @@
}
else
{
- $UserData = only_table_columns($PARAMS, "users");
- // convert supplied password to PasswordHash if set
- if (!empty($PARAMS["Password"])){ $PARAMS["PasswordHash"] = md5($PARAMS["Password"].$result[0]['Salt']); }
- if ($PARAMS["PasswordHash"] == $result[0]['PasswordHash']) // THIS user
+ list($msg, $ReturnedUsers) = _VIEW("users",array(
+ "UserID" => $PARAMS['UserID'],
+ "ScreenName" => $PARAMS['ScreenName'],
+ "EMail" => $PARAMS['EMail'],
+ ));
+ if ($msg == false)
{
+ $ERROR = $ReturnedUsers;
+ }
+ elseif(count($ReturnedUsers) == 1)
+ {
+ $UserData = only_table_columns($PARAMS, "users");
+ $UserData["PasswordHash"] = $ReturnedUsers[0]["PasswordHash"]; // no change
if(strlen($PARAMS["NewPassword"]) > 0) // user is trying to change password
{
- $NewPasswordHash = md5($UserData["NewPassword"].$result[0]['Salt']);
+ $UserData["PasswordHash"] = md5($PARAMS["NewPassword"].$ReturnedUsers[0]['Salt']);
}
- else
+
+ list($pass,$result) = _EDIT("users", $UserData);
+ if (!$pass){ $ERROR = $result; }
+ elseif (count($result) == 1)
{
- $NewPasswordHash = $result[0]["PasswordHash"]; // no change
- }
- if (count($result) == 1)
- {
- $UserData["PasswordHash"] = $NewPasswordHash;
- list($pass,$result) = _EDIT("users", $UserData);
- if (!$pass){ $ERROR = $result; }
- elseif (count($result) == 1)
+ foreach( $result[0] as $key => $val)
{
- foreach( $result[0] as $key => $val)
- {
- $OUTPUT["User"][$key] = $val;
- }
+ $OUTPUT["User"][$key] = $val;
}
}
}
- else
- {
- $ERROR = "Passwords do not match or PasswordHash was not provided";
- }
- }
- else
- {
- $ERROR = "That user is not found";
}
}

0 comments on commit 928fd24

Please sign in to comment.
Something went wrong with that request. Please try again.