alerts.module
Search API
module file for Alerts
File
modules/alerts/alerts.moduleView source
- <?php
 - /**
 -  * @file
 -  * module file for Alerts
 - */
 - 
 - 
 - // Define a constant for a "system-generated" alert
 - define('ALERT_SYSTEM_USER_ID', -99);
 - 
 - 
 - 
 - 
 - function alerts_menu() {
 -   $items = array();
 -   
 -   $items["alerts"] = array(
 -     "title" => "Alerts%ALERTS_ADVISEE_ALERTS_COUNT%", 
 -     "page_callback" => "fp_render_form",
 -     "page_arguments" => array("alerts_advisees_alerts_form"),
 -     "access_arguments" => array("view_advisee_alerts"),
 -     "tab_family" => "alerts",
 -     "weight" => 10,
 -     "type" => MENU_TYPE_TAB,
 -     "page_settings" => array(    
 -       "menu_links" => array(         
 -         0 => array(
 -           "text" => "Dashboard",
 -           "path" => "main",          
 -         ),
 -       ),
 -     ),    
 -   );  
 -   
 -   
 -   $items["advisee-activities"] = array(
 -     "title" => "Advisee Activities",
 -     "page_callback" => "alerts_display_advisee_activities_page",
 -     "access_arguments" => array('can_view_advisee_activity_records'),
 -     "type" => MENU_TYPE_TAB,
 -     'tab_family' => 'alerts',
 -     'weight' => 20,
 -     "page_settings" => array(
 -       "menu_links" => array(         
 -         0 => array(
 -           "text" => "Dashboard",
 -           "path" => "main",          
 -         ),
 -       ),
 -     ),
 -   );
 -     
 -     
 -   // Settings screen
 -   $items["admin/config/alerts-settings"] = array(
 -     "title" => "Alerts settings",                                                
 -     "description" => "Configure settings for Alerts in the system",
 -     "page_callback" => "fp_render_form",
 -     "page_arguments" => array("alerts_settings_form", "system_settings"),
 -     "access_arguments" => array("administer_alerts"),
 -     "page_settings" => array(                                        
 -       "page_hide_report_error" => TRUE,
 -       "menu_links" => array(                    
 -         0 => array(                                               
 -           "text" => "Admin Console",                   
 -           "path" => "admin-tools/admin",                                                           
 -         ),                                                                         
 -       ),
 -       "menu_icon" => fp_get_module_path('system') . "/icons/bell.png",                                                               
 -     ),    
 -     "type" => MENU_TYPE_NORMAL_ITEM,            
 -     "tab_parent" => "admin-tools/admin",    
 -   );
 -     
 -   
 -   
 -   return $items;
 - }
 - 
 - 
 - function alerts_settings_form($school_id = 0) {
 -   $form = array();
 -   
 -   $school_id = intval($school_id);
 -   
 -   $fs = "";  // The field name suffix.  We will add this to the end of all of our field names.  If this is the default school, leave blank.
 -   if (module_enabled("schools")) {
 -     $school_name = schools_get_school_name_for_id($school_id);
 -     fp_set_title(t("Configure %school Alerts settings", array('%school' => $school_name)));
 -     if ($school_id !== 0) {
 -       $fs = "~~school_" . $school_id;
 -     }
 -   }
 -   
 -   $form['school_id'] = array(
 -     'type' => 'hidden',
 -     'value' => $school_id,
 -   );  
 -   
 -   
 -   $form['alerts_tags' . $fs] = array(
 -     'label' => t("Tags"),
 -     'type' => 'textarea',
 -     'value' => variable_get_for_school("alerts_tags", "", $school_id, TRUE),
 -     'description' => t("These are tags wich may be selected when creating a new Alert.
 -                         Enter tags one per line.  For example: 
 -                         <br>   Academics<br>   Financial Aid<br>   English"),
 -     
 -   );
 -     
 -     
 -   
 -   return $form;
 - }
 - 
 - 
 - 
 - 
 - 
 - 
 - 
 - /**
 -  * implements hook_menu_handle_replacement_pattern
 -  */
 - function alerts_menu_handle_replacement_pattern($str) {
 -       
 -   if (strstr($str, "%ALERTS_ADVISEE_ALERTS_COUNT%")) {
 -     // Get our count.
 -     $alert_counts = fp_get_alert_count_by_type();        
 -     $c = intval($alert_counts['alerts']['alert']['unread']);
 -     
 -     $x = "";
 -     if ($c > 0) {
 -       $x .= " ($c)";
 -     }  
 -     
 -     $str = str_replace("%ALERTS_ADVISEE_ALERTS_COUNT%", $x, $str);
 -   }    
 -   
 -   return $str;
 - }
 - 
 - 
 - 
 - 
 - /**
 -  * Implements hook_get_count_for_alert_type
 -  * 
 -  * Set and Return back "unread" (not in content_last_access)
 -  * 
 -  */
 - function alerts_get_alert_count_by_type($account = NULL) {
 -   global $user;
 -   if ($account === NULL) $account = $user;
 -   
 -   if ($account->id == 0) return FALSE;
 -   
 -   $rtn = array();
 -   $types = array('alert'); 
 -   
 -   // We need to know this user's list of advisees.
 -   $advisees = advise_get_advisees($account->cwid);
 -   $advisee_line = "";
 -   if ($advisees && count($advisees) > 0) {
 -     
 -     $advisees_list = "'" . join("','", $advisees) . "'";
 -     
 -     $advisee_line = " AND b.field__student_id IN (" . $advisees_list . ") ";
 -   }
 -   else {
 -     $advisee_line = " AND b.field__student_id IN ('') ";  // Meaning, no advisees.  We do this so as not to break the queries and return back ALL alerts.
 -   }
 -   
 -   // If you have no advisees, that's OK, because you might have alerts which are targetting you.  
 -   $total_count = $read_count = 0;  
 -   foreach ($types as $type) {
 -         
 -     $total_count = intval(db_result(db_query("SELECT COUNT(*) as mycount 
 -                       FROM content__$type b,                                            
 -                            content n
 -                      WHERE n.type = ?
 -                      AND n.published = 1
 -                      AND n.delete_flag = 0
 -                      AND b.vid = n.vid
 -                      AND b.cid = n.cid
 -                      AND b.field__exclude_advisor != 1
 -                      $advisee_line ", array($type)))); 
 -     
 -     
 -     // Also search for alerts which are targeting the account user.
 -     $total_count += intval(db_result(db_query("SELECT COUNT(*) as mycount 
 -                       FROM content__$type b,                                            
 -                            content n
 -                      WHERE n.type = ?
 -                      AND n.published = 1
 -                      AND n.delete_flag = 0
 -                      AND b.vid = n.vid
 -                      AND b.cid = n.cid
 -                      AND b.field__target_faculty_id = ?
 -                       ", array($type, $account->cwid))));     
 -     
 -     
 -     ////////////////////////
 -     // Get Read count for alerts
 -     
 -     
 -     
 -     $read_count = intval(db_result(db_query("SELECT COUNT(*) as mycount 
 -                       FROM content_last_access a,
 -                            content__$type b,                                            
 -                            content n
 -                      WHERE n.type = ?
 -                      AND n.published = 1
 -                      AND n.delete_flag = 0
 -                      AND n.cid = a.cid                     
 -                      AND b.vid = n.vid
 -                      AND n.cid = b.cid
 -                      AND b.field__exclude_advisor != 1
 -                      $advisee_line
 -                      AND a.user_id = ?", array($type, $account->id))));
 -     
 -     
 -     // Also search for read alerts which are targeting the account user.
 -     $read_count += intval(db_result(db_query("SELECT COUNT(*) as mycount 
 -                       FROM content_last_access a,
 -                            content__$type b,                                            
 -                            content n
 -                      WHERE n.type = ?
 -                      AND n.published = 1
 -                      AND n.delete_flag = 0
 -                      AND n.cid = a.cid                     
 -                      AND b.vid = n.vid
 -                      AND n.cid = b.cid
 -                      AND b.field__target_faculty_id = ?                     
 -                      AND a.user_id = ?", array($type, $account->cwid, $account->id))));
 -         
 -     
 -     
 -     $rtn[$type]['total'] = $total_count;
 -     $rtn[$type]['read'] = $read_count;
 -     $rtn[$type]['unread'] = $total_count - $read_count; 
 -         
 -         
 -     // TODO:  A setting such that "read" is actually "closed" and "unread" means "open".    
 -         
 -         
 -   } // foreach types 
 -   
 -   return $rtn;
 -   
 - } // alerts_get_alert_count_by_type
 - 
 - 
 - 
 - 
 - 
 - /**
 -  * Display all advisee activities since the beginning of time, thanks to pager query.
 -  * 
 -  *  
 -  *  
 -  */
 - function alerts_display_advisee_activities_page() {
 -   global $user;
 -     
 -   $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;
 - } // alerts_display_advisee_activities_page
 - 
 - 
 - 
 - 
 - 
 - 
 - /**
 -  * Displays alerts for our various advisees.
 -  */
 - function alerts_advisees_alerts_form($only_student_id = "", $limit = 25) {
 -   global $user;  
 -   $html = "";
 -   $form = array();
 -   
 -   
 -   fp_set_title('');
 -     
 -   fp_add_css(fp_get_module_path('alerts') . '/css/style.css');
 -   
 -   $students_line = "'$only_student_id'";
 -   
 -   if ($only_student_id == "") {  
 -     $student_ids = advise_get_advisees($user->cwid);    
 -     if ($student_ids && count($student_ids) > 0) {
 -       $students_line = "'" . join("','", $student_ids) . "'";
 -     }
 -   }
 -   
 -   
 -   $filter_status = @trim($_SESSION['alerts_filter_status']);
 -   $filter_line = "";
 -   $filter_params = array();
 -   
 -   $filter_params[':faculty_id'] = $user->cwid;
 -   
 -   if ($filter_status) {
 -     $filter_line = "AND field__alert_status = :status";
 -     $filter_params[":status"] = $filter_status;
 -   }
 -   
 -   // filter options form.  Ex:  Status
 -   $form['filter_status'] = array(
 -     'label' => t('Filter by:'),
 -     'type' => 'select',
 -     'options' => array('open' => 'Open', 'closed' => 'Closed'),
 -     'value' => $filter_status,
 -   );
 -   
 -   $form['submit_btn'] = array(
 -     'type' => 'submit',
 -     'value' => t('Submit'),
 -   );
 -   
 -   
 -   
 -   $table_headers = array();
 -   $table_headers[] = array("label" => t("Actions"));  
 -   $table_headers[] = array("label" => t("Status"), "field" => "field__alert_status");
 -   if (!$only_student_id) {  
 -     $table_headers[] = array("label" => t("Student"));
 -   }  
 -   $table_headers[] = array("label" => t("To Faculty/Staff"));  
 -   $table_headers[] = array("label" => t("Short Description"));  
 -   $table_headers[] = array("label" => t("Author"));  
 -   $table_headers[] = array("label" => t("Updated"), "field" => "n.updated");
 -   
 -   // Set our initial sort, if none is already set.   
 -   theme_table_header_sortable_set_initial_sort('n.updated', 'DESC');
 -   
 -   
 -   $html .= "<table border='0' class='advisees-alerts'>";
 -   // Draw our our table headers, with links....
 -   $html .= 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);  
 -               
 -   
 -   // 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__alert a, content n
 -                    WHERE 
 -                     (
 -                       (field__student_id IN ($students_line) AND a.field__exclude_advisor != 1)
 -                          OR
 -                       (field__target_faculty_id = :faculty_id)
 -                     ) 
 -                    AND a.vid = n.vid
 -                    AND a.cid = n.cid
 -                    AND n.delete_flag = 0
 -                    AND n.published = 1  
 -                    $filter_line                                  
 -                    $order_by", $filter_params, $limit, 0, "SELECT COUNT(DISTINCT(a.cid)) FROM content__alert a, content n
 -                                                                                                          WHERE 
 -                                                                                                           (
 -                                                                                                             (field__student_id IN ($students_line) AND a.field__exclude_advisor != 1)
 -                                                                                                                OR
 -                                                                                                             (field__target_faculty_id = :faculty_id)
 -                                                                                                           ) 
 -                                                                                                          AND a.vid = n.vid
 -                                                                                                          AND a.cid = n.cid
 -                                                                                                          AND n.delete_flag = 0
 -                                                                                                          AND n.published = 1
 -                                                                                                          $filter_line
 -                                                                                                          $order_by");  
 - 
 -   while ($cur = db_fetch_object($res)) {
 -     $cid = $cur->cid;
 -     $content = content_load($cid);
 -         
 -     $updated = format_date($content->updated, 'short');
 -     $author = "System";
 -     if ($content->user_id != ALERT_SYSTEM_USER_ID) {
 -       $tuser = fp_load_user($content->user_id);
 -       $author = fp_get_faculty_name($tuser->cwid);
 -     }
 -     
 -     $bool_no_student = TRUE;
 -     $student_id = $content->field__student_id['value'];
 -     $faculty_id = $content->field__target_faculty_id['value'];
 -     $student_name = t("N/A");
 -     if ($student_id) {
 -       $bool_no_student = FALSE;
 -       $student_name = fp_get_student_name($student_id, TRUE);
 -     }
 -     $faculty_name = t("- Advisor -");
 -     if ($faculty_id) {
 -       $faculty_name = fp_get_faculty_name($faculty_id);
 -     }    
 -         
 -         
 -         
 -     $extra_class = "";
 -     // If this content hasn't been read by this user, mark as "unread"
 -     if (!content_get_last_access($cid)) {
 -       $extra_class .= " unread";
 -     }    
 -     
 -     $student_url = fp_url('student-profile', "current_student_id=$student_id");
 -     $view_url = fp_url("content/$cid", "window_mode=popup&content_tabs=false");
 -     $dtitle = t("View Alert");
 -     $view_link = "<a href='javascript:fpOpenLargeIframeDialog(\"$view_url\",\"$dtitle\");' title='" . t("View") . "' class='action-link' ><i class='fa fa-eye'></i></a>";    
 - 
 -     $student_profile_link = "<a href='$student_url' title='" . t("Student Profile") . "' class='action-link'><i class='fa fa-user'></i></a>";
 -     if ($only_student_id || $bool_no_student == TRUE) $student_profile_link = "";    
 -     
 -       
 -     $edit_link = "";    
 -     if (user_has_permission('can_edit_alerts')) {
 -       $edit_url = fp_url("content/$cid/edit", "window_mode=popup&content_tabs=false");
 -       $dtitle = t("Edit Alert");
 -       $edit_link = "<a href='javascript:fpOpenLargeIframeDialog(\"$edit_url\",\"$dtitle\");' title='" . t("Edit") . "' class='action-link'><i class='fa fa-pencil'></i></a>";
 -     }    
 -         
 -     $remove_link = "";
 -     if (user_has_permission('can_remove_alerts')) {
 -       // Load dialog with a custom "remove" screen.  Either "Yes" or "Cancel".  If we hit yes, we redirect to wherever we are supposed to, just as if we saved.  Cancel closes
 -       // the dialog window.
 -       $remove_url = fp_url("content/$cid/remove", "window_mode=popup&content_tabs=false&type=alert");
 -       $dtitle = t("Remove Alert");
 -       $remove_link = "<a href='javascript:fpOpenLargeIframeDialog(\"$remove_url\",\"$dtitle\");' title='" . t("Remove") . "' class='action-link action-link-remove'><i class='fa fa-remove'></i></a>";
 -       
 -              
 -     }
 -     
 -         
 -         
 -     $html .= "
 -       <tr class='{$content->field__alert_status['value']} $extra_class'>
 -         <td class='actions'>$view_link $edit_link $remove_link $student_profile_link</td>
 -         <td class='status'>{$content->field__alert_status['display_value']}</td>
 -         ";
 -         if ($only_student_id == "") {
 -           $html .= "<td class='student'>$student_name</td>";
 -         }
 -      $html .= "        
 -         <td class='faculty'>$faculty_name</td>
 -         <td class='short-desc'><div class='short-desc-wrapper'>{$content->title}</div></td>
 -         <td class='author'>$author</td>
 -         <td class='updated'>$updated</td>
 -       </tr>
 -     ";
 -   } // while cur
 - 
 -   
 -   $html .= "</table>";
 -   
 -   $html .= theme_pager(array(t('« newest'), t('‹ newer'), '', t('older ›'), t('oldest »')));
 -     
 -   
 -   
 -   $form['mark_table'] = array(
 -     'type' => 'markup',
 -     'value' => $html,
 -   );
 -   
 -   
 -   
 -   
 -   return $form;
 - } // alerts_advisees_alerts_form
 - 
 - 
 - 
 - /**
 -  * Our main goal with this submit handler is just to place our filter values
 -  * into a session variable, so we can remember them later.
 -  */
 - function alerts_advisees_alerts_form_submit($form, $form_state) {
 -     
 -   $filter_status = @trim($form_state['values']['filter_status']);
 -   $_SESSION['alerts_filter_status'] = $filter_status;
 -   
 - }
 - 
 - 
 - 
 - 
 - 
 - 
 - /**
 -  * For use with the content module.  We will register our custom content type(s)
 -  * for use with this module.
 -  */
 - function alerts_content_register_content_type() {
 -   global $current_student_id;
 -   $school_id = db_get_school_id_for_student_id($current_student_id);    
 -     
 -   
 -   $arr = array();
 -   
 -   $arr['alert'] = array(
 -     'title' => 'Alert',
 -     'description' => 'Signal an alert, notification, or issue to be resolved for a student.',
 -     'settings' => array(
 -       'title' => array(
 -         'label' => t('Title / Short Description'),    
 -         'weight' => 15,    
 -       ),
 -     ),
 -   );
 -   
 - 
 -   $arr['activity_record'] = array(
 -     'title' => 'Activity Record',
 -     'description' => 'This is generally created directly by FlightPath, and is a note that some activity has occured which, while not an alert, should be
 -                         brought to the advisors attention.  For example, the student sent a text message, or opened an email.',
 -     'settings' => array(
 -       'title' => array(
 -         'label' => t('Title / Short Description'),    
 -         'weight' => 15,    
 -       ),
 -     ),
 -   );
 - 
 -   
 -   
 -   
 -   // If we are in a popup (dialog)...
 -   if (@$_GET['window_mode'] == 'popup') {
 -     // We want to make sure we redirect to our handler URL, which will close the dialog.
 -     $arr['alert']['settings']['#redirect'] = array(
 -       'path' => 'content-dialog-handle-after-save',
 -       'query' => '',        
 -     );
 - 
 -     // We want to make sure we redirect to our handler URL, which will close the dialog.
 -     $arr['activity_record']['settings']['#redirect'] = array(
 -       'path' => 'content-dialog-handle-after-save',
 -       'query' => '',        
 -     );
 - 
 -     
 -   }
 -   
 -   
 -   
 -   
 -   $fields = array();
 - 
 -   $fields['student_id'] = array(
 -     'type' => 'textfield',
 -     'label' => 'Student',
 -     'weight' => 10,
 -   );
 - 
 -   $fields['target_faculty_id'] = array(
 -     'type' => 'hidden',
 -     'value' => '', 
 -   );
 - 
 -   $fields['exclude_advisor'] = array(
 -     'type' => 'hidden',
 -     'value' => '0',
 -   );
 - 
 - 
 -       
 -   $fields['alert_status'] = array(
 -     'type' => 'select',
 -     'label' => 'Status',
 -     'options' => array(
 -       'open' => t('Open'),
 -       'closed' => t('Closed'),
 -     ),
 -     'required' => TRUE,
 -     'hide_please_select' => TRUE,
 -     'weight' => 40,
 -   );
 - 
 -   
 -     
 -   $options = csv_to_form_api_array(variable_get_for_school('alerts_tags', '', $school_id), "\n");
 -   $fields['tags'] = array(
 -     'type' => 'checkboxes',
 -     'options' => $options,
 -     'label' => 'Tags',
 -     'weight' => 60,
 -   );  
 - 
 -     
 -   $fields['alert_msg'] = array(
 -     'type' => 'textarea_editor',  
 -     'label' => 'Message',
 -     'filter' => 'basic',
 -     'weight' => 70,    
 -   );
 - 
 -   
 -   
 -   $fields['visibility'] = array(
 -     'type' => 'radios',  
 -     'label' => 'Visible to:',
 -     'options' => array('public' => 'Anyone (incl. student)', 'faculty' => 'Faculty/Staff only'),   
 -     'weight' => 80,    
 -   );
 -     
 -   $arr['alert']['fields'] = $fields;
 -   
 - 
 -   ///////////////////////////////////
 -   $fields = array();
 - 
 -   $fields['student_id'] = array(
 -     'type' => 'textfield',
 -     'label' => 'Student',
 -     'weight' => 10,
 -   );
 - 
 -   $fields['faculty_id'] = array(
 -     'type' => 'textfield',
 -     'label' => 'Faculty',
 -     'weight' => 15,
 -     'description' => 'optional',
 -   );
 - 
 -       
 -   $fields['activity_type'] = array(
 -     'type' => 'select',
 -     'label' => 'Activity Type (sets the icon)',
 -     'options' => array(
 -       'alert' => t('Alert - Bell'),
 -       'mail' => t('Mail - Envelope'),
 -       'comment' => t('Comment - txt message'),
 -       'calendar' => t('Calendar - appointment related'),
 -     ),
 -     'required' => TRUE,
 -     'hide_please_select' => TRUE,
 -     'weight' => 40,
 -   );
 - 
 - 
 -   $arr['activity_record']['fields'] = $fields;
 -       
 -   
 -   
 -   
 -   
 -       
 -   
 -   return $arr;
 -   
 - } // hook_content_register_content_type
 - 
 - 
 - 
 - function alerts_form_alter(&$form, $form_id) {
 -   
 - if ($form_id == 'content_edit_content_form') {
 -     if (@$form['type']['value'] == 'alert') {
 - 
 -       fp_add_css(fp_get_module_path('alerts') . '/css/style.css');      
 -         
 -       $db = get_global_database_handler();
 -       
 -       // If this is a NEW form, then check for values in the URL to auto-fill.      
 -       if ($form['cid']['value'] === 'new') {
 -         
 -         if (isset($_GET['student_id'])) {
 -           $form['student_id']['value'] = $_GET['student_id'];
 -           
 -           $form['student_id']['attributes'] = array('class' => 'hidden');
 -           $extra_mark = "";
 -           
 -           if ($form['student_id']['value'] != "") {
 -             $form['mark_to'] = array(
 -               'type' => 'markup',
 -               'value' => "<div class='alert-field-mark alert-student'>
 -                                  " . $db->get_student_name($form['student_id']['value'], TRUE) . "<span class='alert-student-extra-mark'>$extra_mark</span>
 -                           </div>",
 -               'weight' => $form['student_id']['weight'], 
 -             );          
 -           }
 -           
 -         } // if _GET[student_id]
 -       } // if "new"
 -       else {
 -         // This is NOT new!  We display display the student information and hide the field.
 -                 
 -         $form['student_id']['attributes'] = array('class' => 'hidden');
 -         $extra_mark = "";
 -         if ($form['student_id']['value'] != "") {
 -           $form['mark_to'] = array(
 -             'type' => 'markup',
 -             'value' => "<div class='alert-field-mark alert-student'>
 -                                " . $db->get_student_name($form['student_id']['value'], TRUE) . "<span class='alert-student-extra-mark'>$extra_mark</span>
 -                         </div>",
 -             'weight' => $form['student_id']['weight'], 
 -           );
 -                 
 -         }
 -         
 -       }
 -       
 -     } // if type == alert
 -   } // if form_id   
 -   
 -   
 - } // hook_form_alter
 - 
 - 
 - 
 - 
 - 
 - 
 - 
 - 
 - function alerts_perm() {
 -   return array(
 -     'administer_alerts' => array(
 -       'title' => t('Administer Alerts Settings'),
 -       'description' => t('The user may configure various settings involving Alerts in the system.'),      
 -     ),
 -     'can_view_alerts' => array(
 -       'title' => t('Can view Alerts'),
 -       'description' => t('The user may view alerts (only "Anyone" by default)'),      
 -     ),
 -     'can_edit_alerts' => array(
 -       'title' => t("Can edit Alerts"),
 -       'description' => t("The user is allowed to change the status (open/closed), comments, etc. of alerts.  Give this
 -                           to users who will be directly responsible for responding to alerts."),
 -     ),
 -     'can_remove_alerts' => array(
 -       'title' => t("Can remove Alerts"),
 -       'description' => t("The user is allowed to 'remove' an alert, effectively deleting it.  It will no longer be available
 -                           in reports."),
 -     ),    
 -     'can_view_faculty_alerts' => array(
 -       'title' => t('View "Faculty/Staff" Alerts'),
 -       'description' => t('The user is allowed to view alerts marked visible for "Faculty/Staff".'),      
 -     ),
 -     'view_advisee_alerts' => array(
 -       'title' => t('View Advisee Alerts'),
 -       'description' => t('The user may view alerts from all of their advisees.  Only give to faculty/staff users.'),
 -     ),
 -     'can_view_advisee_activity_records' => array(
 -       'title' => t('View Activity Records for advisees'),
 -       'description' => t('The user is allowed to view activity records for their advisees.  Give to users who would have such advisees.'),      
 -     ),    
 -     
 -   );
 - }
 - 
 - 
 - 
 - 
 - 
 - 
 - 
 - 
 - 
 - 
 - 
 - 
 - 
 - 
 - 
 - 
 - 
 - 
 - 
 - 
 
Functions
| 
            Name | 
                  Description | 
|---|---|
| alerts_advisees_alerts_form | Displays alerts for our various advisees. | 
| alerts_advisees_alerts_form_submit | Our main goal with this submit handler is just to place our filter values into a session variable, so we can remember them later. | 
| alerts_content_register_content_type | For use with the content module. We will register our custom content type(s) for use with this module. | 
| alerts_display_advisee_activities_page | Display all advisee activities since the beginning of time, thanks to pager query. | 
| alerts_form_alter | |
| alerts_get_alert_count_by_type | Implements hook_get_count_for_alert_type | 
| alerts_menu | |
| alerts_menu_handle_replacement_pattern | implements hook_menu_handle_replacement_pattern | 
| alerts_perm | |
| alerts_settings_form | 
Constants
| 
            Name | 
                  Description | 
|---|---|
| ALERT_SYSTEM_USER_ID | 
