function admin_display_groups

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

This function will display a list of all our groups.

1 string reference to 'admin_display_groups'

File

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

Code

function admin_display_groups() {
  $rtn = "";

  // Do this using $render array, so it can be altered
  // by hook_content_alter

  $render = array();
  $render ['#id'] = 'admin_display_groups';



  $de_catalog_year = admin_get_de_catalog_year();

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

  $db2 = new DatabaseHandler();



  fp_set_title(t("Edit Groups for @de_catalog_year", array("@de_catalog_year" => $de_catalog_year)));


  $render ['upper_links'] = array(
    'value' => "        Options:
                  <ul style='margin-top: 5px;'>          
                    <li>" . l(t("Add a new group to this year"), "admin/groups/edit-group", "de_catalog_year=$de_catalog_year&group_id=new") . "</li>
                    <li>" . l(t("Process all group definitions & catalog repeats for this year"), "admin/groups/process-all-definitions", "de_catalog_year=$de_catalog_year") . "</li>
                    </li>
                  </ul>
                    <div align='center'>" . t("Hint: use CTRL-F to search groups quickly") . "</div>
                ",
  );



  $html = "";
  $html .= "<div class='degrees-filter'>";
  $html .= fp_render_form("admin_groups_list_filter_form");
  $html .= "</div>";


  $render ['degrees_filter'] = array(
    'value' => $html,
  );




  $render ['groups_table_top'] = array(
    'value' => "<table border='0' cellpadding='5' cellspacing='5' width='100%' class='admin-groups-list'>
                <tr>
                  <th>" . t("Title") . "</th>
                  <th>" . t("Internal Name") . "</th>
                  <th align='center'>Pri</th>
                  <th align='center'>i</th>
                  <th align='center'>" . t("Used") . "</th>
                </tr>",
  );



  $on_mouse_over = " onmouseover=\"style.backgroundColor='#FFFF99'\"
              onmouseout=\"style.backgroundColor='white'\" ";


  $params = array();
  $params [":catalog_year"] = $de_catalog_year;

  $filter_name_value = @trim($_SESSION ['groups_filter_name']);
  $filter_school_value = @intval($_SESSION ['groups_filter_school']);
  $extra_where_conditions = "";

  // Let's adjust the query based on filter selections (if any exist)
  if ($filter_name_value) {
    $extra_where_conditions .= " AND (group_name LIKE :name1 OR title LIKE :name2) ";
    $params [":name1"] = "%$filter_name_value%";
    $params [":name2"] = "%$filter_name_value%";
  }



  if (module_enabled('schools')) {
    if ($filter_school_value) {
      $extra_where_conditions .= " AND school_id = :school_id ";
      $params [":school_id"] = $filter_school_value;
    }
  }
  else {
    // schools not enabled, so only search for school = 0
    $extra_where_conditions .= " AND school_id = 0 ";
  }


  watchdog("admin", "Viewed admin groups list. Name filter: $filter_name_value. ($de_catalog_year), school_id: $filter_school_value", array(), WATCHDOG_DEBUG);


  $res = db_query("SELECT * FROM draft_groups
                    WHERE catalog_year = :catalog_year
                    AND delete_flag = 0
                    $extra_where_conditions
                    ORDER BY title, group_name ", $params);
  while ($cur = db_fetch_array($res)) {
    extract($cur, 3, "db");

    $use_count = 0;
    // Find out how many degree plans are using this particular group...

    $res2 = db_query("SELECT count(id) AS count FROM draft_degree_requirements
                WHERE group_id = '?' ", $db_group_id);
    if (db_num_rows($res2) > 0) {
      $cur2 = db_fetch_array($res2);
      $use_count = $cur2 ["count"];
    }

    $def_flag = "";
    if (trim($db_definition) != "") {
      $def_flag = " (*)";
    }

    if ($db_title == "") {
      $db_title = "[" . t("NO TITLE SPECIFIED") . "]";
    }



    $render ['group_row_' . $db_group_id] = array(
      'value' => "<tr $on_mouse_over>
                    <td valign='top' ><a name='group_$db_group_id'></a>
                      " . l($db_title, "admin/groups/edit-group", "group_id=$db_group_id&de_catalog_year=$de_catalog_year") . "
                    </td>
                    <td valign='top' >
                      <i>$db_group_name</i>$def_flag
                    </td>
                    <td valign='top' >
                      $db_priority
                    </td>
                    <td valign='top' >
                      <img src='" . fp_theme_location() . "/images/icons/$db_icon_filename' width='19'>
                    </td>
                    <td valign='top' >
                      $use_count <a href='javascript: adminPopupWindow(\"" . fp_url("admin/groups/popup-show-group-use", "group_id=$db_group_id") . "\");'><i class='fa fa-window-restore'></i></a>
                    </td>
          
                    
                  </tr>
                ",

      'data' => array(
        'group_id' => $db_group_id,
        'db_row' => $cur,
        'use_count' => $use_count,
        'def_flag' => $def_flag,
      ),

    );




  }

  $render ['groups_table_bottom'] = array(
    'value' => "</table>",
  );




  $rtn .= fp_render_content($render);


  return $rtn;
}