Commit dff1a01e authored by Leigh B Stoller's avatar Leigh B Stoller

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

parent 7701cb31
...@@ -568,12 +568,28 @@ $(function () ...@@ -568,12 +568,28 @@ $(function ()
// //
function Toggle(item) { function Toggle(item) {
var name = item.dataset["name"]; 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) { var callback = function(json) {
if (json.code) { 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; return;
} }
if (wait) {
sup.HideModal("#waitwait-modal");
}
LoadProfileTab(); LoadProfileTab();
}; };
sup.CallServerMethod(null, "user-dashboard", "Toggle", sup.CallServerMethod(null, "user-dashboard", "Toggle",
......
...@@ -85,6 +85,12 @@ ...@@ -85,6 +85,12 @@
(<a class="toggle" data-name="web_frozen">Toggle</a>) (<a class="toggle" data-name="web_frozen">Toggle</a>)
</td> </td>
</tr> </tr>
<tr>
<td>Inactive</td>
<td><% if (fields.inactive) { %>Yes<% } else { %>No<% } %>
(<a class="toggle" data-name="inactive">Toggle</a>)
</td>
</tr>
<% } %> <% } %>
</table> </table>
</div> </div>
...@@ -236,6 +236,8 @@ function Do_AccountDetails() ...@@ -236,6 +236,8 @@ function Do_AccountDetails()
$results["nonlocal_id"] = ($target_user->nonlocal_id() ? $results["nonlocal_id"] = ($target_user->nonlocal_id() ?
$target_user->nonlocal_id() : ""); $target_user->nonlocal_id() : "");
$results["last_weblogin"] = DateStringGMT(LASTWEBLOGIN($target_idx)); $results["last_weblogin"] = DateStringGMT(LASTWEBLOGIN($target_idx));
$results["inactive"] = ($target_user->status() ==
TBDB_USERSTATUS_INACTIVE ? true : false);
} }
SPITAJAX_RESPONSE($results); SPITAJAX_RESPONSE($results);
...@@ -306,7 +308,8 @@ function Do_Toggle() ...@@ -306,7 +308,8 @@ function Do_Toggle()
SPITAJAX_ERROR(-1, "Not enough permission"); SPITAJAX_ERROR(-1, "Not enough permission");
return; 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!"); SPITAJAX_ERROR(-1, "User not been activated yet!");
return; return;
} }
...@@ -341,6 +344,18 @@ function Do_Toggle() ...@@ -341,6 +344,18 @@ function Do_Toggle()
return -1; 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") { elseif ($toggle == "foreign_admin") {
$target_user->SetForeignAdmin($target_user->foreign_admin() ? 0 : 1); $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