Commit dff1a01e authored by Leigh Stoller's avatar Leigh Stoller

Add a toggle to reactivate users on the user's admin page (Portal only).

parent 7701cb31
......@@ -568,12 +568,28 @@ $(function ()
//
function Toggle(item) {
var name = item.dataset["name"];
var wait = false;
// These take longer to show the wait modal.
if (name == "admin" || name == "inactive") {
sup.ShowModal("#waitwait-modal");
wait = true;
}
var callback = function(json) {
if (json.code) {
sup.SpitOops("oops", json.value);
if (wait) {
sup.HideModal("#waitwait-modal", function () {
sup.SpitOops("oops", json.value);
});
}
else {
sup.SpitOops("oops", json.value);
}
return;
}
if (wait) {
sup.HideModal("#waitwait-modal");
}
LoadProfileTab();
};
sup.CallServerMethod(null, "user-dashboard", "Toggle",
......
......@@ -85,6 +85,12 @@
(<a class="toggle" data-name="web_frozen">Toggle</a>)
</td>
</tr>
<tr>
<td>Inactive</td>
<td><% if (fields.inactive) { %>Yes<% } else { %>No<% } %>
(<a class="toggle" data-name="inactive">Toggle</a>)
</td>
</tr>
<% } %>
</table>
</div>
......@@ -236,6 +236,8 @@ function Do_AccountDetails()
$results["nonlocal_id"] = ($target_user->nonlocal_id() ?
$target_user->nonlocal_id() : "");
$results["last_weblogin"] = DateStringGMT(LASTWEBLOGIN($target_idx));
$results["inactive"] = ($target_user->status() ==
TBDB_USERSTATUS_INACTIVE ? true : false);
}
SPITAJAX_RESPONSE($results);
......@@ -306,7 +308,8 @@ function Do_Toggle()
SPITAJAX_ERROR(-1, "Not enough permission");
return;
}
if ($target_user->status() != TBDB_USERSTATUS_ACTIVE) {
if ($target_user->status() != TBDB_USERSTATUS_ACTIVE &&
$target_user->status() != TBDB_USERSTATUS_INACTIVE) {
SPITAJAX_ERROR(-1, "User not been activated yet!");
return;
}
......@@ -341,6 +344,18 @@ function Do_Toggle()
return -1;
}
}
elseif ($toggle == "inactive") {
$newstatus = ($target_user->IsActive() ?
TBDB_USERSTATUS_INACTIVE : TBDB_USERSTATUS_ACTIVE);
$command = ($target_user->IsActive() ? "deactivate" : "reactivate");
$target_user->SetStatus($newstatus);
if (SUEXEC($this_uid, $TBADMINGROUP,
"webtbacct $command $target_uid", SUEXEC_ACTION_CONTINUE)) {
SPITAJAX_ERROR(-1, $suexec_output);
return -1;
}
}
elseif ($toggle == "foreign_admin") {
$target_user->SetForeignAdmin($target_user->foreign_admin() ? 0 : 1);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment