admin_edit_group_form

4.x admin.groups.inc admin_edit_group_form()

This function lets the user edit a group.

File

modules/admin/admin.groups.inc, line 263

Code

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

  $de_catalog_year = admin_get_de_catalog_year();
  $group_id = $_REQUEST["group_id"];

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


  $form["#redirect"] = array(
    "path" => "admin/groups/edit-group",
    "query" => "group_id=$group_id&de_catalog_year=$de_catalog_year",
  );


  if (user_has_permission("can_view_advanced")) {
    $form["mark" . $m++] = array(
      "type" => "markup",
      "value" => " <span class='tenpt' style='background-color: yellow; margin-left: 20px;'>
          adv: group_id = $group_id.
          Used by:
          <a href='javascript: adminPopupWindow(\"" . fp_url("admin/groups/popup-show-group-use", "group_id=$group_id") . "\");'>[degrees]</a>
          </span>",
    );
  }

  $group = new Group($group_id, null, -1, false, true);
  //print_pre($group->to_string());
  $group->load_descriptive_data();

  fp_set_title(t("Edit Group:") . " $group->title ($de_catalog_year)");

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

  $form["set_definition"] = array(
    "type" => "hidden",
    "value" => urlencode($group->definition),
  );

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

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

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


  // Actually draw the form out.
  $form["title"] = array(
    "type" => "textfield",
    "label" => t("Group title:"),
    "value" => $group->title,
    "maxlength" => 100,
    "popup_description" => t("This is what FlightPath uses to refer to this group in screens and popups.
                        Ex: Free Electives, Art Electives, Core Humanities, etc."),
  );

  $form["group_name"] = array(
    "type" => "textfield",
    "label" => t("Internal group name:"),
    "value" => $group->group_name,
    "maxlength" => 100,
    "popup_description" => t("The \"group's name\" is internal to FlightPath, and is never seen by the average user.
                        You may use this to distinguish between groups with the same title. Ex:
                        major_electives_sr and major_electives_jr.  The field may be considered
                        optional, but it is highly recommended you enter something here for your
                        own clarity later on.  It is OK to have the same group title and name."),
  );


  $form["priority"] = array(
    "type" => "textfield",
    "label" => t("Priority:"),
    "value" => $group->priority,
    "maxlength" => 10,
    "size" => 10,
    "popup_description" => t("This should be a number, and it is very important, because it determines the
                        order in which courses are assigned to groups in FlightPath.
                        Higher numbers fill in FIRST!  So a group with a priority of 100 would fill in before
                        a group with a priority of 30."),
  );


  $form["icon_filename"] = array(
    "type" => "hidden",
    "label" => t("Icon:"),
    "value" => $group->icon_filename,
    "suffix" => "
                <img src='" . fp_theme_location() . "/images/icons/$group->icon_filename' width='19'>
                $group->icon_filename
                &nbsp; &nbsp;
                <a href='javascript: adminPopupWindow(\"" . base_path() . "/admin/groups/popup-select-icon&group_id=$group_id\");'>[select another]</a>
                ",
  );


  $form["definition"] = array(
    "type" => "markup",
    "label" => t("Definition:"),
    "value" => "<label>" . t("Definition:") . "</label><i>" . nl2br($group->definition) . "</i>",
    "prefix" => "<div style='overflow: auto; max-height: 150px;' class='admin-groups-show-definition'>",
    "suffix" => "</div><a href='javascript: adminPopupWindow(\"" . base_path() . "/admin/groups/popup-edit-definition&de_catalog_year=$de_catalog_year&group_id=$group_id\");'
                            >[" . t("edit definition") . "]</a>",
  );


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


  $courses = admin_get_group_courses($group);
  $form["courses"] = array(
    "type" => "textarea",
    "label" => t("Required Courses:"),
    "rows" => 17,
    "cols" => 80,
    "value" => $courses,
  );
  // if a definition was specified, we need to disable the courses textarea.
  if (trim($group->definition)) {
    $form["courses"]["attributes"] = "readonly=readonly style='background-color: #ccc;' ";
    $form["courses"]["prefix"] = "<div class='admin-groups-courses-disabled'>
                                 " . t("Note: Because a definition was specified, you cannot directly
                                      edit the Required Courses.  Manage these courses using the
                                      Edit Definition popup window.") . "</div>";

  }



  $form["data_entry_comment"] = array(
    "type" => "textarea",
    "label" => t("Optional Comment: (only seen by other FlightPath administrators)"),
    "rows" => 3,
    "cols" => 80,
    "value" => $group->data_entry_comment,
  );


  $form["submit"] = array(
    "type" => "submit",
    "value" => "Submit",
    "prefix" => "<hr>",
  );

  $form["mark" . $m++] = array(
    "type" => "markup",
    "value" => "<div align='right'>
                      " . t("Delete this group?") . " <input type='button' value='X'
                      onClick='adminDeleteGroup(\"$group_id\");'>
                    </div>",
  );



  return $form;
}