function user_user_roles_form

6.x user.module user_user_roles_form()
4.x user.module user_user_roles_form()
5.x user.module user_user_roles_form()

This form allows the user to manage the roles in the system.

File

modules/user/user.module, line 383

Code

function user_user_roles_form() {
  $form = array();

  fp_add_css(fp_get_module_path("user") . "/css/user.css");
  fp_add_js(fp_get_module_path("admin") . "/js/admin.js");



  $form ["mark" . $m++] = array(
    "type" => "markup",
    "value" => t("Roles are able to be assigned permissions in FlightPath, and then users are assigned
                those roles.  You may not remove the two roles, 'anonymous user' and 'authenticated user'.
                Those are assigned automatically when the user logs in or out.
                However, you may add as many more roles as you wish.")
      . "<br><br><b>" . t("roles:") . "</b>
                <table style='padding-left: 20px;'>",
  );

  $res = db_query("SELECT * FROM roles ORDER BY rid");
  while ($cur = db_fetch_array($res)) {

    $key = $cur ["rid"];
    $value = $cur ["name"];

    $prompt_link = fp_get_js_prompt_link("Enter a new name to change this role to:", $value, "document.getElementById(\"element-perform_action2\").value=\"edit~_~$key~_~\" + response; document.getElementById(\"fp-form-user_user_roles_form\").submit(); ", t("edit")) . "  |  ";
    $confirm_link = fp_get_js_confirm_link(t("Are you sure you wish to delete this role?\\nIt will be removed from users' accounts.  This action cannot be undone.\\n\\nProceed?"), "document.getElementById(\"element-perform_action2\").value=\"del~_~$key\"; document.getElementById(\"fp-form-user_user_roles_form\").submit(); ", t("delete"));

    if ($key == 1 || $key == 2) {
      $prompt_link = $confirm_link = "";
    }

    $form ["mark" . $m++] = array(
      "type" => "markup",
      "value" => "<tr><td>$value</td><td>" . $prompt_link . " 
                  " . $confirm_link . "</td></tr>",
    );
  }

  $form ["mark" . $m++] = array(
    "type" => "markup",
    "value" => "</table>",
  );

  $form ["perform_action2"] = array(
    "type" => "hidden",
  );

  $form ["new_role"] = array(
    "type" => "textfield",
    "label" => t("Add a new role:"),
  );

  $form ["submit"] = array(
    "type" => "submit",
    "value" => t("Add new"),
  );

  return $form;
}