alerts.module

  1. 7.x modules/alerts/alerts.module
  2. 6.x modules/alerts/alerts.module

module file for Alerts

File

modules/alerts/alerts.module
View source
  1. <?php
  2. /**
  3. * @file
  4. * module file for Alerts
  5. */
  6. // Define a constant for a "system-generated" alert
  7. define('ALERT_SYSTEM_USER_ID', -99);
  8. function alerts_menu() {
  9. $items = array();
  10. $items["alerts"] = array(
  11. "title" => "Alerts%ALERTS_ADVISEE_ALERTS_COUNT%",
  12. "page_callback" => "fp_render_form",
  13. "page_arguments" => array("alerts_advisees_alerts_form"),
  14. "access_arguments" => array("view_advisee_alerts"),
  15. "tab_family" => "alerts",
  16. "weight" => 10,
  17. "type" => MENU_TYPE_TAB,
  18. "page_settings" => array(
  19. "menu_links" => array(
  20. 0 => array(
  21. "text" => "Dashboard",
  22. "path" => "main",
  23. ),
  24. ),
  25. ),
  26. );
  27. $items["advisee-activities"] = array(
  28. "title" => "Advisee Activities",
  29. "page_callback" => "alerts_display_advisee_activities_page",
  30. "access_arguments" => array('can_view_advisee_activity_records'),
  31. "type" => MENU_TYPE_TAB,
  32. 'tab_family' => 'alerts',
  33. 'weight' => 20,
  34. "page_settings" => array(
  35. "menu_links" => array(
  36. 0 => array(
  37. "text" => "Dashboard",
  38. "path" => "main",
  39. ),
  40. ),
  41. ),
  42. );
  43. // Settings screen
  44. $items["admin/config/alerts-settings"] = array(
  45. "title" => "Alerts settings",
  46. "description" => "Configure settings for Alerts in the system",
  47. "page_callback" => "fp_render_form",
  48. "page_arguments" => array("alerts_settings_form", "system_settings"),
  49. "access_arguments" => array("administer_alerts"),
  50. "page_settings" => array(
  51. "page_hide_report_error" => TRUE,
  52. "menu_links" => array(
  53. 0 => array(
  54. "text" => "Admin Console",
  55. "path" => "admin-tools/admin",
  56. ),
  57. ),
  58. "menu_icon" => fp_get_module_path('system') . "/icons/bell.png",
  59. ),
  60. "type" => MENU_TYPE_NORMAL_ITEM,
  61. "tab_parent" => "admin-tools/admin",
  62. );
  63. return $items;
  64. }
  65. function alerts_settings_form($school_id = 0) {
  66. $form = array();
  67. $school_id = intval($school_id);
  68. $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.
  69. if (module_enabled("schools")) {
  70. $school_name = schools_get_school_name_for_id($school_id);
  71. fp_set_title(t("Configure %school Alerts settings", array('%school' => $school_name)));
  72. if ($school_id !== 0) {
  73. $fs = "~~school_" . $school_id;
  74. }
  75. }
  76. $form['school_id'] = array(
  77. 'type' => 'hidden',
  78. 'value' => $school_id,
  79. );
  80. $form['alerts_tags' . $fs] = array(
  81. 'label' => t("Tags"),
  82. 'type' => 'textarea',
  83. 'value' => variable_get_for_school("alerts_tags", "", $school_id, TRUE),
  84. 'description' => t("These are tags wich may be selected when creating a new Alert.
  85. Enter tags one per line. For example:
  86. <br> &nbsp; Academics<br> &nbsp; Financial Aid<br> &nbsp; English"),
  87. );
  88. return $form;
  89. }
  90. /**
  91. * implements hook_menu_handle_replacement_pattern
  92. */
  93. function alerts_menu_handle_replacement_pattern($str) {
  94. if (strstr($str, "%ALERTS_ADVISEE_ALERTS_COUNT%")) {
  95. // Get our count.
  96. $alert_counts = fp_get_alert_count_by_type();
  97. $c = intval($alert_counts['alerts']['alert']['unread']);
  98. $x = "";
  99. if ($c > 0) {
  100. $x .= " ($c)";
  101. }
  102. $str = str_replace("%ALERTS_ADVISEE_ALERTS_COUNT%", $x, $str);
  103. }
  104. return $str;
  105. }
  106. /**
  107. * Implements hook_get_count_for_alert_type
  108. *
  109. * Set and Return back "unread" (not in content_last_access)
  110. *
  111. */
  112. function alerts_get_alert_count_by_type($account = NULL) {
  113. global $user;
  114. if ($account === NULL) $account = $user;
  115. if ($account->id == 0) return FALSE;
  116. $rtn = array();
  117. $types = array('alert');
  118. // We need to know this user's list of advisees.
  119. $advisees = advise_get_advisees($account->cwid);
  120. $advisee_line = "";
  121. if ($advisees && count($advisees) > 0) {
  122. $advisees_list = "'" . join("','", $advisees) . "'";
  123. $advisee_line = " AND b.field__student_id IN (" . $advisees_list . ") ";
  124. }
  125. else {
  126. $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.
  127. }
  128. // If you have no advisees, that's OK, because you might have alerts which are targetting you.
  129. $total_count = $read_count = 0;
  130. foreach ($types as $type) {
  131. $total_count = intval(db_result(db_query("SELECT COUNT(*) as mycount
  132. FROM content__$type b,
  133. content n
  134. WHERE n.type = ?
  135. AND n.published = 1
  136. AND n.delete_flag = 0
  137. AND b.vid = n.vid
  138. AND b.cid = n.cid
  139. AND b.field__exclude_advisor != 1
  140. $advisee_line ", array($type))));
  141. // Also search for alerts which are targeting the account user.
  142. $total_count += intval(db_result(db_query("SELECT COUNT(*) as mycount
  143. FROM content__$type b,
  144. content n
  145. WHERE n.type = ?
  146. AND n.published = 1
  147. AND n.delete_flag = 0
  148. AND b.vid = n.vid
  149. AND b.cid = n.cid
  150. AND b.field__target_faculty_id = ?
  151. ", array($type, $account->cwid))));
  152. ////////////////////////
  153. // Get Read count for alerts
  154. $read_count = intval(db_result(db_query("SELECT COUNT(*) as mycount
  155. FROM content_last_access a,
  156. content__$type b,
  157. content n
  158. WHERE n.type = ?
  159. AND n.published = 1
  160. AND n.delete_flag = 0
  161. AND n.cid = a.cid
  162. AND b.vid = n.vid
  163. AND n.cid = b.cid
  164. AND b.field__exclude_advisor != 1
  165. $advisee_line
  166. AND a.user_id = ?", array($type, $account->id))));
  167. // Also search for read alerts which are targeting the account user.
  168. $read_count += intval(db_result(db_query("SELECT COUNT(*) as mycount
  169. FROM content_last_access a,
  170. content__$type b,
  171. content n
  172. WHERE n.type = ?
  173. AND n.published = 1
  174. AND n.delete_flag = 0
  175. AND n.cid = a.cid
  176. AND b.vid = n.vid
  177. AND n.cid = b.cid
  178. AND b.field__target_faculty_id = ?
  179. AND a.user_id = ?", array($type, $account->cwid, $account->id))));
  180. $rtn[$type]['total'] = $total_count;
  181. $rtn[$type]['read'] = $read_count;
  182. $rtn[$type]['unread'] = $total_count - $read_count;
  183. // TODO: A setting such that "read" is actually "closed" and "unread" means "open".
  184. } // foreach types
  185. return $rtn;
  186. } // alerts_get_alert_count_by_type
  187. /**
  188. * Display all advisee activities since the beginning of time, thanks to pager query.
  189. *
  190. *
  191. *
  192. */
  193. function alerts_display_advisee_activities_page() {
  194. global $user;
  195. $rtn = "";
  196. fp_add_css(fp_get_module_path('alerts') . '/css/style.css');
  197. fp_set_title('');
  198. // Needs to only be within my advisees list....
  199. $student_ids = advise_get_advisees($user->cwid);
  200. $students_line = "''";
  201. if ($student_ids && count($student_ids) > 0) {
  202. $students_line = "'" . join("','", $student_ids) . "'";
  203. }
  204. $icons = array(
  205. 'alert' => 'fa-bell-o',
  206. 'mail' => 'fa-envelope-o',
  207. 'comment' => 'fa-comment-o',
  208. 'calendar' => 'fa-calendar-o',
  209. );
  210. if ($students_line) {
  211. $students_line = " AND field__student_id IN ($students_line) ";
  212. }
  213. $table_headers = array();
  214. $table_headers[] = array("label" => "Type", "field" => "field__activity_type");
  215. $table_headers[] = array("label" => "Student");
  216. $table_headers[] = array("label" => "Description", "field" => "title");
  217. $table_headers[] = array("label" => "Posted", "field" => "n.updated");
  218. // Set our initial sort, if none is already set.
  219. theme_table_header_sortable_set_initial_sort('n.updated', 'DESC');
  220. $rtn .= "<table border='0' class='advisees-alerts'>";
  221. // Draw our our table headers, with links....
  222. $rtn .= theme_table_header_sortable($table_headers);
  223. // Get our order by clause based on selected table header, if any.
  224. $order_by = theme_table_header_sortable_order_by($table_headers);
  225. $filter_line = "";
  226. $filter_params = array();
  227. $limit = 20;
  228. // Now, we are going to search for alerts about these students, in the form of a pager query.
  229. // Query for alerts for this student. We will be using a pager_query, so we can display a complete history, if we wish.
  230. $res = pager_query("SELECT DISTINCT(a.cid) FROM content__activity_record a, content n
  231. WHERE a.vid = n.vid
  232. AND a.cid = n.cid
  233. AND n.delete_flag = 0
  234. AND n.published = 1
  235. $students_line
  236. $filter_line
  237. $order_by", $filter_params, $limit, 0, "SELECT COUNT(DISTINCT(a.cid)) FROM content__activity_record a, content n
  238. WHERE a.vid = n.vid
  239. AND a.cid = n.cid
  240. AND n.delete_flag = 0
  241. AND n.published = 1
  242. $students_line
  243. $filter_line
  244. $order_by");
  245. while ($cur = db_fetch_object($res)) {
  246. $cid = $cur->cid;
  247. $content = content_load($cid);
  248. $student_name = fp_get_student_name($content->field__student_id['value'], TRUE);
  249. $disp_date = date("m/d/Y g:ia", convert_time($content->updated));
  250. $icon = $icons[$content->field__activity_type['value']];
  251. $rtn .= "
  252. <tr>
  253. <td class='type'><i class='fa $icon'></i></td>
  254. <td class='student'>$student_name</td>
  255. <td class='short-desc'><div class='short-desc-wrapper'>{$content->title}</div></td>
  256. <td class='updated'>$disp_date</td>
  257. </tr>
  258. ";
  259. } // while cur
  260. $rtn .= "</table>";
  261. $rtn .= theme_pager(array(t('« newest'), t('‹ newer'), '', t('older ›'), t('oldest »')));
  262. return $rtn;
  263. } // alerts_display_advisee_activities_page
  264. /**
  265. * Displays alerts for our various advisees.
  266. */
  267. function alerts_advisees_alerts_form($only_student_id = "", $limit = 25) {
  268. global $user;
  269. $html = "";
  270. $form = array();
  271. fp_set_title('');
  272. fp_add_css(fp_get_module_path('alerts') . '/css/style.css');
  273. $students_line = "'$only_student_id'";
  274. if ($only_student_id == "") {
  275. $student_ids = advise_get_advisees($user->cwid);
  276. if ($student_ids && count($student_ids) > 0) {
  277. $students_line = "'" . join("','", $student_ids) . "'";
  278. }
  279. }
  280. $filter_status = @trim($_SESSION['alerts_filter_status']);
  281. $filter_line = "";
  282. $filter_params = array();
  283. $filter_params[':faculty_id'] = $user->cwid;
  284. if ($filter_status) {
  285. $filter_line = "AND field__alert_status = :status";
  286. $filter_params[":status"] = $filter_status;
  287. }
  288. // filter options form. Ex: Status
  289. $form['filter_status'] = array(
  290. 'label' => t('Filter by:'),
  291. 'type' => 'select',
  292. 'options' => array('open' => 'Open', 'closed' => 'Closed'),
  293. 'value' => $filter_status,
  294. );
  295. $form['submit_btn'] = array(
  296. 'type' => 'submit',
  297. 'value' => t('Submit'),
  298. );
  299. $table_headers = array();
  300. $table_headers[] = array("label" => t("Actions"));
  301. $table_headers[] = array("label" => t("Status"), "field" => "field__alert_status");
  302. if (!$only_student_id) {
  303. $table_headers[] = array("label" => t("Student"));
  304. }
  305. $table_headers[] = array("label" => t("To Faculty/Staff"));
  306. $table_headers[] = array("label" => t("Short Description"));
  307. $table_headers[] = array("label" => t("Author"));
  308. $table_headers[] = array("label" => t("Updated"), "field" => "n.updated");
  309. // Set our initial sort, if none is already set.
  310. theme_table_header_sortable_set_initial_sort('n.updated', 'DESC');
  311. $html .= "<table border='0' class='advisees-alerts'>";
  312. // Draw our our table headers, with links....
  313. $html .= theme_table_header_sortable($table_headers);
  314. // Get our order by clause based on selected table header, if any.
  315. $order_by = theme_table_header_sortable_order_by($table_headers);
  316. // Now, we are going to search for alerts about these students, in the form of a pager query.
  317. // Query for alerts for this student. We will be using a pager_query, so we can display a complete history, if we wish.
  318. $res = pager_query("SELECT DISTINCT(a.cid) FROM content__alert a, content n
  319. WHERE
  320. (
  321. (field__student_id IN ($students_line) AND a.field__exclude_advisor != 1)
  322. OR
  323. (field__target_faculty_id = :faculty_id)
  324. )
  325. AND a.vid = n.vid
  326. AND a.cid = n.cid
  327. AND n.delete_flag = 0
  328. AND n.published = 1
  329. $filter_line
  330. $order_by", $filter_params, $limit, 0, "SELECT COUNT(DISTINCT(a.cid)) FROM content__alert a, content n
  331. WHERE
  332. (
  333. (field__student_id IN ($students_line) AND a.field__exclude_advisor != 1)
  334. OR
  335. (field__target_faculty_id = :faculty_id)
  336. )
  337. AND a.vid = n.vid
  338. AND a.cid = n.cid
  339. AND n.delete_flag = 0
  340. AND n.published = 1
  341. $filter_line
  342. $order_by");
  343. while ($cur = db_fetch_object($res)) {
  344. $cid = $cur->cid;
  345. $content = content_load($cid);
  346. $updated = format_date($content->updated, 'short');
  347. $author = "System";
  348. if ($content->user_id != ALERT_SYSTEM_USER_ID) {
  349. $tuser = fp_load_user($content->user_id);
  350. $author = fp_get_faculty_name($tuser->cwid);
  351. }
  352. $bool_no_student = TRUE;
  353. $student_id = $content->field__student_id['value'];
  354. $faculty_id = $content->field__target_faculty_id['value'];
  355. $student_name = t("N/A");
  356. if ($student_id) {
  357. $bool_no_student = FALSE;
  358. $student_name = fp_get_student_name($student_id, TRUE);
  359. }
  360. $faculty_name = t("- Advisor -");
  361. if ($faculty_id) {
  362. $faculty_name = fp_get_faculty_name($faculty_id);
  363. }
  364. $extra_class = "";
  365. // If this content hasn't been read by this user, mark as "unread"
  366. if (!content_get_last_access($cid)) {
  367. $extra_class .= " unread";
  368. }
  369. $student_url = fp_url('student-profile', "current_student_id=$student_id");
  370. $view_url = fp_url("content/$cid", "window_mode=popup&content_tabs=false");
  371. $dtitle = t("View Alert");
  372. $view_link = "<a href='javascript:fpOpenLargeIframeDialog(\"$view_url\",\"$dtitle\");' title='" . t("View") . "' class='action-link' ><i class='fa fa-eye'></i></a>";
  373. $student_profile_link = "<a href='$student_url' title='" . t("Student Profile") . "' class='action-link'><i class='fa fa-user'></i></a>";
  374. if ($only_student_id || $bool_no_student == TRUE) $student_profile_link = "";
  375. $edit_link = "";
  376. if (user_has_permission('can_edit_alerts')) {
  377. $edit_url = fp_url("content/$cid/edit", "window_mode=popup&content_tabs=false");
  378. $dtitle = t("Edit Alert");
  379. $edit_link = "<a href='javascript:fpOpenLargeIframeDialog(\"$edit_url\",\"$dtitle\");' title='" . t("Edit") . "' class='action-link'><i class='fa fa-pencil'></i></a>";
  380. }
  381. $remove_link = "";
  382. if (user_has_permission('can_remove_alerts')) {
  383. // 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
  384. // the dialog window.
  385. $remove_url = fp_url("content/$cid/remove", "window_mode=popup&content_tabs=false&type=alert");
  386. $dtitle = t("Remove Alert");
  387. $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>";
  388. }
  389. $html .= "
  390. <tr class='{$content->field__alert_status['value']} $extra_class'>
  391. <td class='actions'>$view_link $edit_link $remove_link $student_profile_link</td>
  392. <td class='status'>{$content->field__alert_status['display_value']}</td>
  393. ";
  394. if ($only_student_id == "") {
  395. $html .= "<td class='student'>$student_name</td>";
  396. }
  397. $html .= "
  398. <td class='faculty'>$faculty_name</td>
  399. <td class='short-desc'><div class='short-desc-wrapper'>{$content->title}</div></td>
  400. <td class='author'>$author</td>
  401. <td class='updated'>$updated</td>
  402. </tr>
  403. ";
  404. } // while cur
  405. $html .= "</table>";
  406. $html .= theme_pager(array(t('« newest'), t('‹ newer'), '', t('older ›'), t('oldest »')));
  407. $form['mark_table'] = array(
  408. 'type' => 'markup',
  409. 'value' => $html,
  410. );
  411. return $form;
  412. } // alerts_advisees_alerts_form
  413. /**
  414. * Our main goal with this submit handler is just to place our filter values
  415. * into a session variable, so we can remember them later.
  416. */
  417. function alerts_advisees_alerts_form_submit($form, $form_state) {
  418. $filter_status = @trim($form_state['values']['filter_status']);
  419. $_SESSION['alerts_filter_status'] = $filter_status;
  420. }
  421. /**
  422. * For use with the content module. We will register our custom content type(s)
  423. * for use with this module.
  424. */
  425. function alerts_content_register_content_type() {
  426. global $current_student_id;
  427. $school_id = db_get_school_id_for_student_id($current_student_id);
  428. $arr = array();
  429. $arr['alert'] = array(
  430. 'title' => 'Alert',
  431. 'description' => 'Signal an alert, notification, or issue to be resolved for a student.',
  432. 'settings' => array(
  433. 'title' => array(
  434. 'label' => t('Title / Short Description'),
  435. 'weight' => 15,
  436. ),
  437. ),
  438. );
  439. $arr['activity_record'] = array(
  440. 'title' => 'Activity Record',
  441. 'description' => 'This is generally created directly by FlightPath, and is a note that some activity has occured which, while not an alert, should be
  442. brought to the advisors attention. For example, the student sent a text message, or opened an email.',
  443. 'settings' => array(
  444. 'title' => array(
  445. 'label' => t('Title / Short Description'),
  446. 'weight' => 15,
  447. ),
  448. ),
  449. );
  450. // If we are in a popup (dialog)...
  451. if (@$_GET['window_mode'] == 'popup') {
  452. // We want to make sure we redirect to our handler URL, which will close the dialog.
  453. $arr['alert']['settings']['#redirect'] = array(
  454. 'path' => 'content-dialog-handle-after-save',
  455. 'query' => '',
  456. );
  457. // We want to make sure we redirect to our handler URL, which will close the dialog.
  458. $arr['activity_record']['settings']['#redirect'] = array(
  459. 'path' => 'content-dialog-handle-after-save',
  460. 'query' => '',
  461. );
  462. }
  463. $fields = array();
  464. $fields['student_id'] = array(
  465. 'type' => 'textfield',
  466. 'label' => 'Student',
  467. 'weight' => 10,
  468. );
  469. $fields['target_faculty_id'] = array(
  470. 'type' => 'hidden',
  471. 'value' => '',
  472. );
  473. $fields['exclude_advisor'] = array(
  474. 'type' => 'hidden',
  475. 'value' => "0",
  476. );
  477. $fields['alert_status'] = array(
  478. 'type' => 'select',
  479. 'label' => 'Status',
  480. 'options' => array(
  481. 'open' => t('Open'),
  482. 'closed' => t('Closed'),
  483. ),
  484. 'required' => TRUE,
  485. 'hide_please_select' => TRUE,
  486. 'weight' => 40,
  487. );
  488. $options = csv_to_form_api_array(variable_get_for_school('alerts_tags', '', $school_id), "\n");
  489. $fields['tags'] = array(
  490. 'type' => 'checkboxes',
  491. 'options' => $options,
  492. 'label' => 'Tags',
  493. 'weight' => 60,
  494. );
  495. $fields['alert_msg'] = array(
  496. 'type' => 'textarea_editor',
  497. 'label' => 'Message',
  498. 'filter' => 'basic',
  499. 'weight' => 70,
  500. );
  501. $fields['visibility'] = array(
  502. 'type' => 'radios',
  503. 'label' => 'Visible to:',
  504. 'options' => array('public' => 'Anyone (incl. student)', 'faculty' => 'Faculty/Staff only'),
  505. 'weight' => 80,
  506. );
  507. $arr['alert']['fields'] = $fields;
  508. ///////////////////////////////////
  509. $fields = array();
  510. $fields['student_id'] = array(
  511. 'type' => 'textfield',
  512. 'label' => 'Student',
  513. 'weight' => 10,
  514. );
  515. $fields['faculty_id'] = array(
  516. 'type' => 'textfield',
  517. 'label' => 'Faculty',
  518. 'weight' => 15,
  519. 'description' => 'optional',
  520. );
  521. $fields['activity_type'] = array(
  522. 'type' => 'select',
  523. 'label' => 'Activity Type (sets the icon)',
  524. 'options' => array(
  525. 'alert' => t('Alert - Bell'),
  526. 'mail' => t('Mail - Envelope'),
  527. 'comment' => t('Comment - txt message'),
  528. 'calendar' => t('Calendar - appointment related'),
  529. ),
  530. 'required' => TRUE,
  531. 'hide_please_select' => TRUE,
  532. 'weight' => 40,
  533. );
  534. $arr['activity_record']['fields'] = $fields;
  535. return $arr;
  536. } // hook_content_register_content_type
  537. function alerts_form_alter(&$form, $form_id) {
  538. if ($form_id == 'content_edit_content_form') {
  539. if (@$form['type']['value'] == 'alert') {
  540. fp_add_css(fp_get_module_path('alerts') . '/css/style.css');
  541. $db = get_global_database_handler();
  542. // If this is a NEW form, then check for values in the URL to auto-fill.
  543. if ($form['cid']['value'] === 'new') {
  544. if (isset($_GET['student_id'])) {
  545. $form['student_id']['value'] = $_GET['student_id'];
  546. $form['student_id']['attributes'] = array('class' => 'hidden');
  547. $extra_mark = "";
  548. if ($form['student_id']['value'] != "") {
  549. $form['mark_to'] = array(
  550. 'type' => 'markup',
  551. 'value' => "<div class='alert-field-mark alert-student'>
  552. " . $db->get_student_name($form['student_id']['value'], TRUE) . "<span class='alert-student-extra-mark'>$extra_mark</span>
  553. </div>",
  554. 'weight' => $form['student_id']['weight'],
  555. );
  556. }
  557. } // if _GET[student_id]
  558. } // if "new"
  559. else {
  560. // This is NOT new! We display display the student information and hide the field.
  561. $form['student_id']['attributes'] = array('class' => 'hidden');
  562. $extra_mark = "";
  563. if ($form['student_id']['value'] != "") {
  564. $form['mark_to'] = array(
  565. 'type' => 'markup',
  566. 'value' => "<div class='alert-field-mark alert-student'>
  567. " . $db->get_student_name($form['student_id']['value'], TRUE) . "<span class='alert-student-extra-mark'>$extra_mark</span>
  568. </div>",
  569. 'weight' => $form['student_id']['weight'],
  570. );
  571. }
  572. }
  573. } // if type == alert
  574. } // if form_id
  575. } // hook_form_alter
  576. function alerts_perm() {
  577. return array(
  578. 'administer_alerts' => array(
  579. 'title' => t('Administer Alerts Settings'),
  580. 'description' => t('The user may configure various settings involving Alerts in the system.'),
  581. ),
  582. 'can_view_alerts' => array(
  583. 'title' => t('Can view Alerts'),
  584. 'description' => t('The user may view alerts (only "Anyone" by default)'),
  585. ),
  586. 'can_edit_alerts' => array(
  587. 'title' => t("Can edit Alerts"),
  588. 'description' => t("The user is allowed to change the status (open/closed), comments, etc. of alerts. Give this
  589. to users who will be directly responsible for responding to alerts."),
  590. ),
  591. 'can_remove_alerts' => array(
  592. 'title' => t("Can remove Alerts"),
  593. 'description' => t("The user is allowed to 'remove' an alert, effectively deleting it. It will no longer be available
  594. in reports."),
  595. ),
  596. 'can_view_faculty_alerts' => array(
  597. 'title' => t('View "Faculty/Staff" Alerts'),
  598. 'description' => t('The user is allowed to view alerts marked visible for "Faculty/Staff".'),
  599. ),
  600. 'view_advisee_alerts' => array(
  601. 'title' => t('View Advisee Alerts'),
  602. 'description' => t('The user may view alerts from all of their advisees. Only give to faculty/staff users.'),
  603. ),
  604. 'can_view_advisee_activity_records' => array(
  605. 'title' => t('View Activity Records for advisees'),
  606. 'description' => t('The user is allowed to view activity records for their advisees. Give to users who would have such advisees.'),
  607. ),
  608. );
  609. }

Functions

Namesort descending 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