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. if ($tuser && isset($tuser->cwid)) {
  351. $author = fp_get_faculty_name($tuser->cwid);
  352. }
  353. }
  354. $bool_no_student = TRUE;
  355. $student_id = $content->field__student_id['value'];
  356. $faculty_id = $content->field__target_faculty_id['value'];
  357. $student_name = t("N/A");
  358. if ($student_id) {
  359. $bool_no_student = FALSE;
  360. $student_name = fp_get_student_name($student_id, TRUE);
  361. }
  362. $faculty_name = t("- Advisor -");
  363. if ($faculty_id) {
  364. $faculty_name = fp_get_faculty_name($faculty_id);
  365. }
  366. $extra_class = "";
  367. // If this content hasn't been read by this user, mark as "unread"
  368. if (!content_get_last_access($cid)) {
  369. $extra_class .= " unread";
  370. }
  371. $student_url = fp_url('student-profile', "current_student_id=$student_id");
  372. $view_url = fp_url("content/$cid", "window_mode=popup&content_tabs=false");
  373. $dtitle = t("View Alert");
  374. $view_link = "<a href='javascript:fpOpenLargeIframeDialog(\"$view_url\",\"$dtitle\");' title='" . t("View") . "' class='action-link' ><i class='fa fa-eye'></i></a>";
  375. $student_profile_link = "<a href='$student_url' title='" . t("Student Profile") . "' class='action-link'><i class='fa fa-user'></i></a>";
  376. if ($only_student_id || $bool_no_student == TRUE) $student_profile_link = "";
  377. $edit_link = "";
  378. if (user_has_permission('can_edit_alerts')) {
  379. $edit_url = fp_url("content/$cid/edit", "window_mode=popup&content_tabs=false");
  380. $dtitle = t("Edit Alert");
  381. $edit_link = "<a href='javascript:fpOpenLargeIframeDialog(\"$edit_url\",\"$dtitle\");' title='" . t("Edit") . "' class='action-link'><i class='fa fa-pencil'></i></a>";
  382. }
  383. $remove_link = "";
  384. if (user_has_permission('can_remove_alerts')) {
  385. // 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
  386. // the dialog window.
  387. $remove_url = fp_url("content/$cid/remove", "window_mode=popup&content_tabs=false&type=alert");
  388. $dtitle = t("Remove Alert");
  389. $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>";
  390. }
  391. $html .= "
  392. <tr class='{$content->field__alert_status['value']} $extra_class'>
  393. <td class='actions'>$view_link $edit_link $remove_link $student_profile_link</td>
  394. <td class='status'>{$content->field__alert_status['display_value']}</td>
  395. ";
  396. if ($only_student_id == "") {
  397. $html .= "<td class='student'>$student_name</td>";
  398. }
  399. $html .= "
  400. <td class='faculty'>$faculty_name</td>
  401. <td class='short-desc'><div class='short-desc-wrapper'>{$content->title}</div></td>
  402. <td class='author'>$author</td>
  403. <td class='updated'>$updated</td>
  404. </tr>
  405. ";
  406. } // while cur
  407. $html .= "</table>";
  408. $html .= theme_pager(array(t('« newest'), t('‹ newer'), '', t('older ›'), t('oldest »')));
  409. $form['mark_table'] = array(
  410. 'type' => 'markup',
  411. 'value' => $html,
  412. );
  413. return $form;
  414. } // alerts_advisees_alerts_form
  415. /**
  416. * Our main goal with this submit handler is just to place our filter values
  417. * into a session variable, so we can remember them later.
  418. */
  419. function alerts_advisees_alerts_form_submit($form, $form_state) {
  420. $filter_status = @trim($form_state['values']['filter_status']);
  421. $_SESSION['alerts_filter_status'] = $filter_status;
  422. }
  423. /**
  424. * For use with the content module. We will register our custom content type(s)
  425. * for use with this module.
  426. */
  427. function alerts_content_register_content_type() {
  428. global $current_student_id;
  429. $school_id = db_get_school_id_for_student_id($current_student_id);
  430. $arr = array();
  431. $arr['alert'] = array(
  432. 'title' => 'Alert',
  433. 'description' => 'Signal an alert, notification, or issue to be resolved for a student.',
  434. 'settings' => array(
  435. 'title' => array(
  436. 'label' => t('Title / Short Description'),
  437. 'weight' => 15,
  438. ),
  439. ),
  440. );
  441. $arr['activity_record'] = array(
  442. 'title' => 'Activity Record',
  443. 'description' => 'This is generally created directly by FlightPath, and is a note that some activity has occured which, while not an alert, should be
  444. brought to the advisors attention. For example, the student sent a text message, or opened an email.',
  445. 'settings' => array(
  446. 'title' => array(
  447. 'label' => t('Title / Short Description'),
  448. 'weight' => 15,
  449. ),
  450. ),
  451. );
  452. // If we are in a popup (dialog)...
  453. if (@$_GET['window_mode'] == 'popup') {
  454. // We want to make sure we redirect to our handler URL, which will close the dialog.
  455. $arr['alert']['settings']['#redirect'] = array(
  456. 'path' => 'content-dialog-handle-after-save',
  457. 'query' => '',
  458. );
  459. // We want to make sure we redirect to our handler URL, which will close the dialog.
  460. $arr['activity_record']['settings']['#redirect'] = array(
  461. 'path' => 'content-dialog-handle-after-save',
  462. 'query' => '',
  463. );
  464. }
  465. $fields = array();
  466. $fields['student_id'] = array(
  467. 'type' => 'textfield',
  468. 'label' => 'Student',
  469. 'weight' => 10,
  470. );
  471. $fields['target_faculty_id'] = array(
  472. 'type' => 'hidden',
  473. 'value' => '',
  474. );
  475. $fields['exclude_advisor'] = array(
  476. 'type' => 'hidden',
  477. 'value' => "0",
  478. );
  479. $fields['alert_status'] = array(
  480. 'type' => 'select',
  481. 'label' => 'Status',
  482. 'options' => array(
  483. 'open' => t('Open'),
  484. 'closed' => t('Closed'),
  485. ),
  486. 'required' => TRUE,
  487. 'hide_please_select' => TRUE,
  488. 'weight' => 40,
  489. );
  490. $options = csv_to_form_api_array(variable_get_for_school('alerts_tags', '', $school_id), "\n");
  491. $fields['tags'] = array(
  492. 'type' => 'checkboxes',
  493. 'options' => $options,
  494. 'label' => 'Tags',
  495. 'weight' => 60,
  496. );
  497. $fields['alert_msg'] = array(
  498. 'type' => 'textarea_editor',
  499. 'label' => 'Message',
  500. 'filter' => 'basic',
  501. 'weight' => 70,
  502. );
  503. $fields['visibility'] = array(
  504. 'type' => 'radios',
  505. 'label' => 'Visible to:',
  506. 'options' => array('public' => 'Anyone (incl. student)', 'faculty' => 'Faculty/Staff only'),
  507. 'weight' => 80,
  508. );
  509. $arr['alert']['fields'] = $fields;
  510. ///////////////////////////////////
  511. $fields = array();
  512. $fields['student_id'] = array(
  513. 'type' => 'textfield',
  514. 'label' => 'Student',
  515. 'weight' => 10,
  516. );
  517. $fields['faculty_id'] = array(
  518. 'type' => 'textfield',
  519. 'label' => 'Faculty',
  520. 'weight' => 15,
  521. 'description' => 'optional',
  522. );
  523. $fields['activity_type'] = array(
  524. 'type' => 'select',
  525. 'label' => 'Activity Type (sets the icon)',
  526. 'options' => array(
  527. 'alert' => t('Alert - Bell'),
  528. 'mail' => t('Mail - Envelope'),
  529. 'comment' => t('Comment - txt message'),
  530. 'calendar' => t('Calendar - appointment related'),
  531. ),
  532. 'required' => TRUE,
  533. 'hide_please_select' => TRUE,
  534. 'weight' => 40,
  535. );
  536. $arr['activity_record']['fields'] = $fields;
  537. return $arr;
  538. } // hook_content_register_content_type
  539. /**
  540. * Implements hook_content_load.
  541. */
  542. function alerts_content_load(&$content) {
  543. if (!$content || !is_object($content) || $content->type != 'alert') return; // We only care about the 'alert' content type.
  544. // If there are any media files in this alert, search for and add them to the content object so they are displayed.
  545. $cid = $content->cid;
  546. $msg = $content->field__alert_msg['display_value'];
  547. $ttemp = array('', '');
  548. if (strstr($msg, "~~MEDIA~~") && strstr($msg, "~~END_MEDIA~~")) {
  549. $temp = explode("~~MEDIA~~", $msg);
  550. $msg = $temp[0]; // get rid of the media part of the msg.
  551. $ttemp = explode("~~END_MEDIA~~", $temp[1]);
  552. }
  553. $res2 = db_query("SELECT * FROM content_files WHERE cid = ? ORDER BY cid", array($cid));
  554. while ($cur2 = db_fetch_array($res2)) {
  555. $fid = $cur2['fid'];
  556. $file = content_get_uploaded_file($fid);
  557. $img_tag = "<img src='{$file['url']}' style='max-width:200px;height:auto;'>";
  558. $msg .= "<div class='media-attached'><a href='{$file['url']}' target='_BLANK'>
  559. $img_tag
  560. </a></div>";
  561. }
  562. $msg .= $ttemp[1]; // in case there was anything AFTER ~~END_MEDIA~~
  563. // Add it back into our $content now.
  564. $content->field__alert_msg['display_value'] = $msg;
  565. } // hook_content_load
  566. function alerts_form_alter(&$form, $form_id) {
  567. if ($form_id == 'content_edit_content_form') {
  568. if (@$form['type']['value'] == 'alert') {
  569. fp_add_css(fp_get_module_path('alerts') . '/css/style.css');
  570. $db = get_global_database_handler();
  571. // If this is a NEW form, then check for values in the URL to auto-fill.
  572. if ($form['cid']['value'] === 'new') {
  573. if (isset($_GET['student_id'])) {
  574. $form['student_id']['value'] = $_GET['student_id'];
  575. $form['student_id']['attributes'] = array('class' => 'hidden');
  576. $extra_mark = "";
  577. if ($form['student_id']['value'] != "") {
  578. $form['mark_to'] = array(
  579. 'type' => 'markup',
  580. 'value' => "<div class='alert-field-mark alert-student'>
  581. " . $db->get_student_name($form['student_id']['value'], TRUE) . "<span class='alert-student-extra-mark'>$extra_mark</span>
  582. </div>",
  583. 'weight' => $form['student_id']['weight'],
  584. );
  585. }
  586. } // if _GET[student_id]
  587. } // if "new"
  588. else {
  589. // This is NOT new! We display display the student information and hide the field.
  590. $form['student_id']['attributes'] = array('class' => 'hidden');
  591. $extra_mark = "";
  592. if ($form['student_id']['value'] != "") {
  593. $form['mark_to'] = array(
  594. 'type' => 'markup',
  595. 'value' => "<div class='alert-field-mark alert-student'>
  596. " . $db->get_student_name($form['student_id']['value'], TRUE) . "<span class='alert-student-extra-mark'>$extra_mark</span>
  597. </div>",
  598. 'weight' => $form['student_id']['weight'],
  599. );
  600. }
  601. }
  602. } // if type == alert
  603. } // if form_id
  604. } // hook_form_alter
  605. function alerts_perm() {
  606. return array(
  607. 'administer_alerts' => array(
  608. 'title' => t('Administer Alerts Settings'),
  609. 'description' => t('The user may configure various settings involving Alerts in the system.'),
  610. ),
  611. 'can_view_alerts' => array(
  612. 'title' => t('Can view Alerts'),
  613. 'description' => t('The user may view alerts (only "Anyone" by default)'),
  614. ),
  615. 'can_edit_alerts' => array(
  616. 'title' => t("Can edit Alerts"),
  617. 'description' => t("The user is allowed to change the status (open/closed), comments, etc. of alerts. Give this
  618. to users who will be directly responsible for responding to alerts."),
  619. ),
  620. 'can_remove_alerts' => array(
  621. 'title' => t("Can remove Alerts"),
  622. 'description' => t("The user is allowed to 'remove' an alert, effectively deleting it. It will no longer be available
  623. in reports."),
  624. ),
  625. 'can_view_faculty_alerts' => array(
  626. 'title' => t('View "Faculty/Staff" Alerts'),
  627. 'description' => t('The user is allowed to view alerts marked visible for "Faculty/Staff".'),
  628. ),
  629. 'view_advisee_alerts' => array(
  630. 'title' => t('View Advisee Alerts'),
  631. 'description' => t('The user may view alerts from all of their advisees. Only give to faculty/staff users.'),
  632. ),
  633. 'can_view_advisee_activity_records' => array(
  634. 'title' => t('View Activity Records for advisees'),
  635. 'description' => t('The user is allowed to view activity records for their advisees. Give to users who would have such advisees.'),
  636. ),
  637. );
  638. }

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_load Implements hook_content_load.
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