10-19-2010, 05:27 AM
I run a managed DMS, and I specifically didn't want the user to be able to edit their name, comments only their password/email address so I added a new setting. It would be nice if it made it into the standard tree :-
inc.Settings.php
// enable/disable user updating of Name & Comments
var $_enableUserUpdate = false;
out.EditUserData.php
<form action="../op/op.EditUserData.php" enctype="multipart/form-data" method="post" name="form1" onsubmit="return checkForm();">
<table>
<tr>
<td><?php printMLText("password");?>:</td>
<td><input type="Password" name="pwd" size="30"></td>
</tr>
<tr>
<td><?php printMLText("confirm_pwd");?>:</td>
<td><input type="Password" name="pwdconf" size="30"></td>
</tr>
<?php if ($settings->_enableUserUpdate){ ?>
<tr>
<td><?php printMLText("name");?>:</td>
<td><input name="fullname" value="<?php print $user->getFullName();?>" size="30"></td>
</tr> <?php } ?>
<tr>
<td><?php printMLText("email");?>:</td>
<td><input name="email" value="<?php print $user->getEmail();?>" size="30"></td>
</tr>
<?php if ($settings->_enableUserUpdate){ ?>
<tr>
<td><?php printMLText("comment");?>:</td>
<td><textarea name="comment" rows="4" cols="80"><?php print $user->getComment();?></textarea></td>
</tr> <?php } ?>
op.EditUserData.php
$fullname = sanitizeString($_POST["fullname"]);
$email = sanitizeString($_POST["email"]);
$comment = sanitizeString($_POST["comment"]);
if (isset($_POST["pwd"]) && ($_POST["pwd"] != ""))
$user->setPwd(md5($_POST["pwd"]));
if ($settings->_enableUserUpdate){
if ($user->getFullName() != $fullname)
$user->setFullName($fullname);
if ($user->getComment() != $comment)
$user->setComment($comment);
}
if ($user->getEmail() != $email)
$user->setEmail($email);
inc.Settings.php
// enable/disable user updating of Name & Comments
var $_enableUserUpdate = false;
out.EditUserData.php
<form action="../op/op.EditUserData.php" enctype="multipart/form-data" method="post" name="form1" onsubmit="return checkForm();">
<table>
<tr>
<td><?php printMLText("password");?>:</td>
<td><input type="Password" name="pwd" size="30"></td>
</tr>
<tr>
<td><?php printMLText("confirm_pwd");?>:</td>
<td><input type="Password" name="pwdconf" size="30"></td>
</tr>
<?php if ($settings->_enableUserUpdate){ ?>
<tr>
<td><?php printMLText("name");?>:</td>
<td><input name="fullname" value="<?php print $user->getFullName();?>" size="30"></td>
</tr> <?php } ?>
<tr>
<td><?php printMLText("email");?>:</td>
<td><input name="email" value="<?php print $user->getEmail();?>" size="30"></td>
</tr>
<?php if ($settings->_enableUserUpdate){ ?>
<tr>
<td><?php printMLText("comment");?>:</td>
<td><textarea name="comment" rows="4" cols="80"><?php print $user->getComment();?></textarea></td>
</tr> <?php } ?>
op.EditUserData.php
$fullname = sanitizeString($_POST["fullname"]);
$email = sanitizeString($_POST["email"]);
$comment = sanitizeString($_POST["comment"]);
if (isset($_POST["pwd"]) && ($_POST["pwd"] != ""))
$user->setPwd(md5($_POST["pwd"]));
if ($settings->_enableUserUpdate){
if ($user->getFullName() != $fullname)
$user->setFullName($fullname);
if ($user->getComment() != $comment)
$user->setComment($comment);
}
if ($user->getEmail() != $email)
$user->setEmail($email);