function admin_edit_group_form
Search API
7.x admin.groups.inc | 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.
1 string reference to 'admin_edit_group_form'
- schools_form_alter in modules/
schools/ schools.module - Implements hook_form_alter
File
- modules/
admin/ admin.groups.inc, line 575
Code
function admin_edit_group_form() {
$form = array();
$m = 0;
$group_id = $_REQUEST ["group_id"];
$db = get_global_database_handler();
$school_id = 0;
if ($group_id != "new") {
$school_id = $db->get_school_id_for_group_id($group_id, TRUE);
}
$de_catalog_year = admin_get_de_catalog_year(TRUE, $school_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 <b>internal machine name</b> is internal to FlightPath, and is never seen by the average user.
<br>
You may use this to distinguish between groups with the same title.
<br>Ex: <i>major_electives_sr</i> and <i>major_electives_jr</i>.
<br>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,
);
if (!$group->icon_filename) {
$group->icon_filename = "major.gif"; // set a default if none is specified!
}
$form ["icon_filename"] = array(
"type" => "hidden",
"value" => $group->icon_filename,
"weight" => 40,
);
$form ['icon_filename_markup'] = array(
"label" => t("Icon:"),
"value" => "<img src='" . fp_theme_location() . "/images/icons/$group->icon_filename' width='19'>
$group->icon_filename
<a href='javascript: adminPopupWindow(\"" . fp_url("admin/groups/popup-select-icon", "group_id=$group_id") . "\");'>[select another]</a>
",
"weight" => 41,
);
$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,
"popup_description" => t("Note: You may specify <i>hidden</i> courses by placing a - (minus sign) before the course name.
<br> Ex: - ART 101
<br> This will cause ART 101 not to show to the user as a choice, but FlightPath will still automatically fill in ART 101
into this group, if the student completes it.
<br><br>
You may also <i>recommend</i> a course by place a * (asterisk) before the course name.
<br> Ex: * ART 101
<br>This will cause <b>ART 101</b> to appear as bold to the user when viewing the list of courses in this group.
<br><br>
Courses which may be repeated can be specified by placing the number of acceptible repeats in brackets after
the course.
<br>Ex: ART 101 [2]
<br>This means that ART 101 may be repeated up to two times for this group. If using this feature, make sure
that repeats are permissible for this course."),
);
// if a definition was specified, we need to disable the courses textarea.
if (trim($group->definition)) {
$form ["courses"]["attributes"] = array("readonly" => "readonly", "style" => "background-color: #ddd;'");
$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 ["submit"] = array(
"type" => "submit",
"value" => "Submit",
"prefix" => "<hr>",
"weight" => 100,
);
// Advanced options
$elements = array();
$bool_start_closed = TRUE;
if (@trim($group->public_note) != "" || trim($group->data_entry_comment) != "") {
$bool_start_closed = FALSE;
}
$elements ['public_note'] = array(
'type' => 'textarea',
'label' => t('Public Note'),
'rows' => 4,
'value' => @$group->public_note,
'description' => t("You may enter simple HTML in this field. Ex: <b>bold</b> or <i>italics</i>"),
'popup_description' => t("A public note will appear at the top of the group when displayed in the dialog popup in FlightPath."),
"weight" => 50010,
);
$elements ["data_entry_comment"] = array(
"type" => "textarea",
"label" => t("Optional Admin Comment: (only seen by other FlightPath administrators)"),
"rows" => 3,
"cols" => 80,
"value" => $group->data_entry_comment,
"weight" => 90,
);
// Place in our advanced options fs.
$form ['advanced_options_fs'] = array(
'type' => 'cfieldset',
'label' => t('View advanced options'),
'elements' => array($elements),
'start_closed' => $bool_start_closed,
"weight" => 50100,
);
// 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" => 600000,
);
}
return $form;
}