function admin_edit_group_form

6.x admin.groups.inc admin_edit_group_form()
4.x admin.groups.inc admin_edit_group_form()
5.x admin.groups.inc admin_edit_group_form()

This function lets the user edit a group.

File

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

Code

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

  $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>",
      "weight" => 0,
    );
  }

  $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,
    "required" => TRUE,
    "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."),
    "weight" => 10,
  );

  $form ["group_name"] = array(
    "type" => "textfield",
    "label" => t("Internal group machine name:"),
    "value" => $group->group_name,
    "maxlength" => 100,
    "required" => TRUE,
    "popup_description" => t("The group's \"internal machine 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 must be unique within each catalog year, and
                        consist of only letters, numbers, and underscores.  FlightPath will make
                        sure it is unique when you save, and give you a chance to change it if it
                        is not."),
    "weight" => 20,
  );


  $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."),
    "weight" => 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(\"" . fp_url("admin/groups/popup-select-icon", "group_id=$group_id") . "\");'>[select another]</a>
                ",
    "weight" => 40,
  );


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


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


  $courses = admin_get_group_courses($group);
  $form ["courses"] = array(
    "type" => "textarea",
    "label" => t("Required Courses:"),
    "rows" => 17,
    "cols" => 80,
    "value" => $courses,
    "weight" => 70,
  );
  // 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 ["catalog_repeat"] = array(
    "type" => "checkbox",
    "label" => t("Set Catalog Repeats"),
    "value" => $group->db_catalog_repeat,
    "popup_description" => t("If checked, this group will automatically assign specified repeats to courses
                        which are determined to be repeatable for this catalog year.  
                        
                        For example, if you enter
                        ART 101, and in the course catalog that course may be taken two times, then
                        when you save this group the line will be changed to ART 101 [2].
                        
                        This will work with definitions, but will not work in groups with branches.
                        If you are unsure what to select, leave this box unchecked."),
    "weight" => 80,
  );

  $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,
    "weight" => 90,
  );


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

  // Only show delete option based on permission  
  if (user_has_permission("can_delete_data_entry")) {
    $form ["mark" . $m++] = array(
      "type" => "markup",
      "value" => "<div align='right' class='groups-delete-group-wrapper'>
                        " . t("Delete this group?") . " <input type='button' value='X'
                        onClick='adminDeleteGroup(\"$group_id\");'>
                      </div>",
      "weight" => 200,
    );

  }

  return $form;
}