function alerts_display_advisee_activities_page

6.x alerts.module alerts_display_advisee_activities_page()

Display all advisee activities since the beginning of time, thanks to pager query.

File

modules/alerts/alerts.module, line 263
module file for Alerts

Code

function alerts_display_advisee_activities_page() {
  $rtn = "";

  fp_add_css(fp_get_module_path('alerts') . '/css/style.css');

  fp_set_title('');

  // Needs to only be within my advisees list....
  $student_ids = advise_get_advisees($user->cwid);
  $students_line = "''";
  if ($student_ids && count($student_ids) > 0) {
    $students_line = "'" . join("','", $student_ids) . "'";
  }

  $icons = array(
    'alert' => 'fa-bell-o',
    'mail' => 'fa-envelope-o',
    'comment' => 'fa-comment-o',
    'calendar' => 'fa-calendar-o',
  );

  if ($students_line) {
    $students_line = " AND field__student_id IN ($students_line) ";
  }

  $table_headers = array();

  $table_headers [] = array("label" => "Type", "field" => "field__activity_type");
  $table_headers [] = array("label" => "Student");
  $table_headers [] = array("label" => "Description", "field" => "title");

  $table_headers [] = array("label" => "Posted", "field" => "n.updated");

  // Set our initial sort, if none is already set.   
  theme_table_header_sortable_set_initial_sort('n.updated', 'DESC');


  $rtn .= "<table border='0' class='advisees-alerts'>";
  // Draw our our table headers, with links....
  $rtn .= theme_table_header_sortable($table_headers);
  // Get our order by clause based on selected table header, if any.    
  $order_by = theme_table_header_sortable_order_by($table_headers);

  $filter_line = "";
  $filter_params = array();
  $limit = 20;


  // Now, we are going to search for alerts about these students, in the form of a pager query.
  // Query for alerts for this student.  We will be using a pager_query, so we can display a complete history, if we wish.
  $res = pager_query("SELECT DISTINCT(a.cid) FROM content__activity_record a, content n
                     WHERE a.vid = n.vid
                     AND a.cid = n.cid
                     AND n.delete_flag = 0
                     AND n.published = 1
                     $students_line
                     $filter_line                                  
                     $order_by", $filter_params, $limit, 0, "SELECT COUNT(DISTINCT(a.cid)) FROM content__activity_record a, content n
                                                               WHERE a.vid = n.vid
                                                               AND a.cid = n.cid
                                                               AND n.delete_flag = 0
                                                               AND n.published = 1
                                                               $students_line
                                                               $filter_line
                                                               $order_by");





  while ($cur = db_fetch_object($res)) {
    $cid = $cur->cid;
    $content = content_load($cid);

    $student_name = fp_get_student_name($content->field__student_id ['value'], TRUE);

    $disp_date = date("m/d/Y g:ia", convert_time($content->updated));

    $icon = $icons [$content->field__activity_type ['value']];

    $rtn .= "
      <tr>
        <td class='type'><i class='fa $icon'></i></td>
        <td class='student'>$student_name</td>             
        <td class='short-desc'><div class='short-desc-wrapper'>{$content->title}</div></td>
        <td class='updated'>$disp_date</td>
      </tr>
    ";
  } // while cur


  $rtn .= "</table>";

  $rtn .= theme_pager(array(t('« newest'), t('‹ newer'), '', t('older ›'), t('oldest »')));




  return $rtn;
}