This repository has been archived by the owner on Jul 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
EditUser.php
64 lines (60 loc) · 3.18 KB
/
EditUser.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
//Include menu options applicable to all pages of the web site
include("PhpSampleTemplate.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>
Edit User
</title>
<link rel="stylesheet" type="text/css" href="StyleSheet.css" />
</head>
<body>
<?php
// If this was not a post back show the edit user form
if (!isset($_POST['submit'])) {
$user = GraphServiceAccessHelper::getEntry('users',$_GET['id']);
$skypeAccount = isset($user->{Settings::$skypeExtension}) ? $user->{Settings::$skypeExtension} : "";
echo('<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$_GET['id']. '">');
echo('<table>');
echo('<tr><td><b>Display Name:</b></td><td><input type="text" size="20" maxlength="100" name="dname" value="'. $user->{'displayName'}.'"></td></tr>');
echo('<tr><td><b>Mail Alias:</b></td><td><input type="text" size="20" maxlength="15" name="alias" value="'. $user->{'mailNickname'}.'"></td></tr>');
echo ('<input name="id" type="hidden" value='.$_GET['id'].'>');
echo('<tr><td><b>Skype Account:</b></td><td><input type="text" size="20" maxlength="15" name="skypeAccount" value="'. $skypeAccount.'"></td></tr>');
echo('<tr><td><b>Title:</b></td><td><input type="text" size="20" maxlength="15" name="jobTitle" value="'. $user->{'jobTitle'}.'"></td></tr>');
echo('<tr><td><input type="submit" value="submit" name="submit"></td></tr>');
echo('</table>');
echo('</form>');
}
else {
if((empty($_POST["dname"])) or (empty($_POST["alias"]))) {
echo('<p>One of the required fields is empty. Please go back to <a href="EditUser.php'.'?id='.$_POST['id'].'">Update User</a></p>');
}
else {
$displayName = $_POST["dname"];
$alias = $_POST["alias"];
$skypeAccount = $_POST["skypeAccount"];
$jobTitle = $_POST["jobTitle"];
$userEntryInput = array(
'displayName'=> $displayName,
'userPrincipalName' => $alias.'@'.Settings::$appTenantDomainName ,
'mailNickname' => $alias,
Settings::$skypeExtension => $skypeAccount,
'jobTitle' => $jobTitle);
// Update the user
$user = GraphServiceAccessHelper::updateEntry('users',$_POST['id'],$userEntryInput);
//Check to see if we got back an error.
if(!empty($user->{'odata.error'}))
{
$message = $user->{'odata.error'}->{'message'};
echo('<p>User update failed. Service returned error:<b>'.$message->{'value'}. '</b> Please go back to <a href="EditUser.php'.'?id='.$_POST['id'].'">Update User</a></p>');
}
else {
header('Location: DisplayUsers.php');
}
}
}
?>
</body>
</html>