audit.module

This is the Audit module, which provides functionality relating to degree audits.

File

modules/audit/audit.module
View source
  1. <?php
  2. /**
  3. * @file
  4. * This is the Audit module, which provides functionality relating to degree audits.
  5. */
  6. /**
  7. * Implementation of hook_menu
  8. *
  9. */
  10. function audit_menu() {
  11. $items = array();
  12. $items["audit"] = array(
  13. "title" => "Audit",
  14. "page_callback" => "audit_display_audit",
  15. "access_callback" => "audit_can_access_audit", //should the audit tab show up right now, for this user?
  16. "tab_family" => "system",
  17. "page_settings" => array (
  18. "display_currently_advising" => TRUE,
  19. ),
  20. "weight" => 100,
  21. "type" => MENU_TYPE_TAB,
  22. );
  23. // Settings screen
  24. $items["admin/config/audit-settings"] = array(
  25. "title" => "Audit settings",
  26. "description" => "Configure settings for the Audit tab",
  27. "page_callback" => "fp_render_form",
  28. "page_arguments" => array("audit_settings_form", "system_settings"),
  29. "access_arguments" => array("administer_audit"),
  30. "page_settings" => array(
  31. "page_hide_report_error" => TRUE,
  32. "menu_links" => array(
  33. 0 => array(
  34. "text" => "Admin Console",
  35. "path" => "admin-tools/admin",
  36. ),
  37. ),
  38. "menu_icon" => fp_get_module_path('system') . "/icons/report.png",
  39. ),
  40. "type" => MENU_TYPE_NORMAL_ITEM,
  41. "tab_parent" => "admin-tools/admin",
  42. );
  43. // The edit-approval popup...
  44. // audit/popup-edit-approval/TYPE/STUDENT CWID
  45. $items["audit/popup-edit-approval/%/%"] = array(
  46. "title" => "Edit Approval",
  47. "page_callback" => "fp_render_form",
  48. "page_arguments" => array("audit_popup_edit_approval_form", "normal", 2, 3),
  49. "access_arguments" => array("edit_audit_approvals"),
  50. "page_settings" => array(
  51. "page_is_popup" => TRUE,
  52. "page_hide_report_error" => TRUE,
  53. ),
  54. "type" => MENU_TYPE_CALLBACK,
  55. );
  56. return $items;
  57. }
  58. function audit_settings_form($school_id = 0) {
  59. $form = array();
  60. $school_id = intval($school_id);
  61. $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.
  62. if (module_enabled("schools")) {
  63. $school_name = schools_get_school_name_for_id($school_id);
  64. fp_set_title(t("Configure %school Audit settings", array('%school' => $school_name)));
  65. if ($school_id !== 0) {
  66. $fs = "~~school_" . $school_id;
  67. }
  68. }
  69. $form['school_id'] = array(
  70. 'type' => 'hidden',
  71. 'value' => $school_id,
  72. );
  73. $form["audit_approval_types" . $fs] = array(
  74. "label" => t("Enter approval type definitions, one per line:"),
  75. "type" => "textarea",
  76. "rows" => 10,
  77. "value" => variable_get_for_school("audit_approval_types", "coursework ~ Coursework\nmajor_gpa ~ Major GPA\ngraduation_gpa ~ Graduation GPA", $school_id, TRUE),
  78. "description" => t("Enter definitions for the approval types, one per line, like so:
  79. <br>&nbsp;&nbsp;&nbsp; TYPE ~ Title ~ Description
  80. <br>- The TYPE must be unique, and contain ONLY letters, numbers, and underscore (_), and must be no more than 60 characters long. Ex: coursework
  81. <br>- The Title should be relatively short, but has no character limit. Ex: Coursework Requirement
  82. <br>- The Description can be any length, but contain NO line breaks. It can, however, contain HTML.
  83. <br>
  84. <b>You may skip lines between definitions.</b>
  85. <br>Example:
  86. <br>
  87. &nbsp;&nbsp;&nbsp; coursework ~ Coursework ~ The student must complete all coursework.
  88. <br>&nbsp;&nbsp;&nbsp; major_gpa ~ Major GPA ~ The student's major GPA should be at least 2.5.
  89. <br>&nbsp;&nbsp;&nbsp; graduation_gpa ~ Graduation GPA ~ The student's graduation GPA must be at least 2.5."),
  90. );
  91. $school_initials = variable_get_for_school("school_initials", "DEMO", $school_id);
  92. $form["audit_requirement_types" . $fs] = array(
  93. "label" => t("Enter requirement types & labels to display on Audit tab, one per line:"),
  94. "type" => "textarea",
  95. "rows" => 15,
  96. "value" => variable_get_for_school("audit_requirement_types", "g ~ General Requirements\nc ~ Core\nm ~ Major\ndegree ~ Degree", $school_id, TRUE),
  97. "description" => "Enter definitions for the requirement types to display, one per line, like so:
  98. <br>&nbsp;&nbsp;&nbsp; type_code ~ Label
  99. <br>The type_code is one of the 'requirement types' that a course can be defined as. Ex: m, c, etc.
  100. <br><b>Important:</b> The pseudo-code 'degree' must be defined, and it will display totals for the entire degree.
  101. <br><b>Important:</b> To see ONLY local (non-transfer) courses, add _local to the end of the type code. Ex: c_local for Core, not fulfilled by transfer credits.
  102. <br>
  103. For ex:
  104. <br>
  105. &nbsp;&nbsp;&nbsp;g ~ General Requirements
  106. <br>&nbsp;&nbsp;&nbsp;c ~ Core
  107. <br>&nbsp;&nbsp;&nbsp;m ~ Major
  108. <br>&nbsp;&nbsp;&nbsp;degree ~ Degree
  109. <br>&nbsp;&nbsp;&nbsp;c_local ~ Core ($school_initials Courses)
  110. <br>&nbsp;&nbsp;&nbsp;degree_local ~ Degree ($school_initials Courses)
  111. <br>
  112. <b>To insert a BLANK row</b>, for appearances on the Audit tab,
  113. give the entry a unique type_code, and set the label to BLANK (all caps).
  114. Ex:
  115. <br> &nbsp;&nbsp;&nbsp;BLANK_1 ~ BLANK
  116. <br> &nbsp;&nbsp;&nbsp;BLANK_2 ~ BLANK
  117. ",
  118. );
  119. return $form;
  120. }
  121. function audit_settings_form_validate($form, $form_state) {
  122. // The main thing I want to do here is make sure that the key_codes are acceptable machine names.
  123. $val = $form_state["values"]["audit_approval_types"];
  124. $lines = explode("\n", $val);
  125. foreach ($lines as $line) {
  126. if (trim($line) == "") continue;
  127. $temp = explode("~", $line);
  128. $key = trim($temp[0]);
  129. $desc = trim($temp[1]);
  130. // Make sure key and desc both have values.
  131. if (strlen($key) < 2 || strlen($desc) < 2) {
  132. form_error("audit_approval_types", t("KEY_CODEs and Descriptions must be at least 2 characters long. Please revise."));
  133. return;
  134. }
  135. if (strlen($key) > 40) {
  136. form_error("audit_approval_types", t("KEY_CODEs may not be longer than 40 characters. Please revise."));
  137. return;
  138. }
  139. // Make sure that key_code is machine name.
  140. if (fp_get_machine_readable($key) != $key) {
  141. form_error("audit_approval_types", t("KEY_CODEs must only contain letters, numbers, and underscores (_). Please revise."));
  142. return;
  143. }
  144. }
  145. }
  146. /**
  147. * Return an assoc array of approval types.
  148. *
  149. */
  150. function audit_get_approval_types($school_id = 0) {
  151. $rtn = array();
  152. $val = variable_get_for_school("audit_approval_types", "coursework ~ Coursework\nmajor_gpa ~ Major GPA\ngraduation_gpa ~ Graduation GPA", '', $school_id);
  153. $lines = explode("\n", $val);
  154. foreach ($lines as $line) {
  155. if (trim($line) == "") continue;
  156. $temp = explode("~", $line);
  157. $key = trim($temp[0]);
  158. $title = trim($temp[1]);
  159. @$desc = trim($temp[2]);
  160. $rtn[$key] = array (
  161. "title" => $title,
  162. "description" => $desc,
  163. );
  164. }
  165. return $rtn;
  166. }
  167. function audit_get_approval_record($student_id, $approval_type) {
  168. $res = db_query("SELECT * FROM audit_approvals
  169. WHERE student_id = '?'
  170. AND approval_type = '?' ", $student_id, $approval_type);
  171. $cur = db_fetch_array($res);
  172. return $cur;
  173. }
  174. /**
  175. * Returns a simple array of the available approval options in the popup.
  176. *
  177. *
  178. */
  179. function audit_get_approval_options() {
  180. return array("not_complete" => t("Not Complete"), "in_progress" => t("In Progress"), "complete" => t("Complete"), "not_applicable" => t("Not Applicable"));
  181. }
  182. /**
  183. * This is the actual form that will be used to change an audit approval for a student.
  184. *
  185. * @param unknown_type $approval_type
  186. * @param unknown_type $student_id
  187. */
  188. function audit_popup_edit_approval_form($approval_type, $student_id) {
  189. $form = array();
  190. fp_add_css(fp_get_module_path("audit") . "/css/audit.css");
  191. fp_add_js(fp_get_module_path("audit") . "/js/audit.js");
  192. $school_id = db_get_school_id_for_student_id($student_id);
  193. $types = audit_get_approval_types($school_id);
  194. $details = $types[$approval_type];
  195. $approval_type_title = $details["title"];
  196. if ($approval_type_title == "") $approval_type_title = $approval_type;
  197. fp_set_title("Edit approval for " . fp_get_student_name($student_id) . " ($student_id)");
  198. // Get current value from the database
  199. $current_value = "";
  200. $cur = audit_get_approval_record($student_id, $approval_type);
  201. if ($cur && isset($cur['approval_value'])) {
  202. $current_value = $cur["approval_value"];
  203. }
  204. if ($current_value == "") $current_value = "not_complete";
  205. $options = audit_get_approval_options();
  206. $options["in_progress"] = t("In Progress - will be completed when the student's enrolled courses are completed");
  207. $form["approval"] = array(
  208. "type" => "radios",
  209. "label" => t("Please set the completion status for this type:<br><em style='padding-left: 20px;'>$approval_type_title</em>"),
  210. "options" => $options,
  211. "value" => $current_value,
  212. "no_please_select" => TRUE,
  213. /*
  214. "description" => "Legend:<div style='padding-left: 10px;'>Complete - The requirement has been completed.
  215. <br>Not Complete - The requirement has not been completed yet.
  216. <br>In Progress - The requirement will be completed when the student's enrolled courses are completed.",
  217. */
  218. );
  219. $form["comment"] = array(
  220. "type" => "textarea",
  221. "label" => t("Optional comment:"),
  222. "rows" => 3,
  223. "attributes" => array("style" => "width: 90%;"),
  224. "description" => t("When you save this form, a brief entry will be made to the audit comment history.
  225. If you wish, you may add an optional comment at this time to explain your
  226. selection."),
  227. );
  228. $form["submit_btn"] = array(
  229. "type" => "submit",
  230. "value" => "Submit",
  231. );
  232. $form["#attributes"] = array("onSubmit" => "return auditPopupEditApprovalFormSubmit(\"$approval_type\",\"$student_id\");");
  233. watchdog("audit", "popup_edit_approval student_id:$student_id, approval_type:$approval_type", array(), WATCHDOG_DEBUG);
  234. return $form;
  235. }
  236. function audit_display_audit() {
  237. global $current_student_id, $user, $fp, $degree_plan, $screen;
  238. fp_set_title('');
  239. $rtn = "";
  240. fp_add_css(fp_get_module_path("comments") . "/css/comments.css");
  241. fp_add_css(fp_get_module_path("audit") . "/css/audit.css");
  242. fp_add_js(fp_get_module_path("audit") . "/js/audit.js");
  243. // We will re-use code from the advise module, to pre-initialize all of our information for the student.
  244. $temp = advise_display_view();
  245. // We will get rid of the sub tabs and other values we've added.
  246. fp_set_page_sub_tabs(array());
  247. $screen->screen_mode = "not_advising"; // do this so the mini profile doesn't get any options added to it from the advise module.
  248. $student = $fp->student;
  249. $school_id = $student->school_id;
  250. // Get this from settings
  251. $audit_requirement_types = array();
  252. $tlines = explode("\n", variable_get_for_school("audit_requirement_types", "g ~ General Requirements\nc ~ Core\nm ~ Major\ndegree ~ Degree", '', $school_id));
  253. foreach ($tlines as $tline) {
  254. $temp = explode("~", trim($tline));
  255. if (trim($temp[0]) != "") {
  256. $audit_requirement_types[trim($temp[0])] = trim($temp[1]);
  257. }
  258. }
  259. $pol = "";
  260. $rtn .= " <table class='audit-table'> ";
  261. $degree_plan->calculate_progress_hours(TRUE);
  262. $degree_plan->calculate_progress_quality_points(TRUE);
  263. foreach ($degree_plan->gpa_calculations as $gpa_degree_id => $gpa_details) {
  264. if ($gpa_degree_id == 0) {
  265. // This is "overall"
  266. $rtn .= "<tr class='audit-req audit-req-new-degree-title audit-row-$pol audit-req-degree-title-OVERALL'>
  267. <td colspan='3'>" . t("Overall:") . "</td>
  268. </tr>";
  269. $pol = ""; // start over after a blank row
  270. }
  271. else {
  272. // This is a degree.
  273. $dtitle = fp_get_degree_title($gpa_degree_id, TRUE, TRUE);
  274. $rtn .= "<tr class='audit-req audit-req-new-degree-title audit-row-$pol audit-req-degree-title-member-degree'>
  275. <td colspan='3'>$dtitle:</td>
  276. </tr>";
  277. $pol = ""; // start over after a blank row
  278. }
  279. foreach ($audit_requirement_types as $type => $desc) {
  280. $gpa = "";
  281. if ($pol != "even") {
  282. $pol = "even";
  283. }
  284. else {
  285. $pol = "odd";
  286. }
  287. if (@$degree_plan->gpa_calculations[$gpa_degree_id][$type]["qpts_hours"] > 0) {
  288. $gpa = fp_truncate_decimals($degree_plan->gpa_calculations[$gpa_degree_id][$type]["qpts"] / $degree_plan->gpa_calculations[$gpa_degree_id][$type]["qpts_hours"], 3);
  289. }
  290. $percent = "0";
  291. if (@$degree_plan->gpa_calculations[$gpa_degree_id][$type]["total_hours"] > 0) {
  292. $percent = fp_truncate_decimals(($degree_plan->gpa_calculations[$gpa_degree_id][$type]["fulfilled_hours"] / $degree_plan->gpa_calculations[$gpa_degree_id][$type]["total_hours"]) * 100, 2);
  293. }
  294. // Are we trying to judt have a blank row?
  295. if ($desc == "BLANK") { // if description is BLANK, then yes, make this row blank.
  296. $rtn .= "<tr class='audit-req audit-req-BLANK audit-row-$pol audit-row-blank'>
  297. <td colspan='3'>&nbsp; &nbsp;</td>
  298. </tr>";
  299. $pol = ""; // start over after a blank row
  300. continue;
  301. }
  302. // Okay, let's display our row normally now:
  303. $rtn .= "
  304. <tr class='audit-req audit-req-$type audit-row-$pol'>
  305. <td width='25%'>$desc:</td>
  306. <td class='audit-req-hours-percent'><span class='audit-hours'><span class='audit-completed-hours'>{$degree_plan->gpa_calculations[$gpa_degree_id][$type]["fulfilled_hours"]}</span>
  307. / <span class='audit-total-hours'>{$degree_plan->gpa_calculations[$gpa_degree_id][$type]["total_hours"]} hrs</span>
  308. </span>
  309. <span class='audit-percent-completed'>($percent%)</span>
  310. </td>
  311. <td class='audit-req-gpa'>GPA: $gpa ({$degree_plan->gpa_calculations[$gpa_degree_id][$type]["qpts"]} qpts
  312. / {$degree_plan->gpa_calculations[$gpa_degree_id][$type]["qpts_hours"]} qhrs)</td>
  313. </tr>";
  314. } // foreach audit_requirements
  315. } // foreach degreeplan->gpa_calculations
  316. $rtn .= "
  317. <tr>
  318. <td valign='top'>Footnotes & Messages:</td>
  319. <td colspan='2'><table border='0' width='100%'>
  320. " . $screen->build_footnotes(FALSE) . "
  321. </table>
  322. </td>
  323. </tr>
  324. ";
  325. $rtn .= "
  326. <tr>
  327. <td valign='top'>Approvals:</td>
  328. <td colspan='2'>
  329. <table border='0' class='approvals' width='100%'>
  330. ";
  331. // Get approval types from our setting
  332. $types = audit_get_approval_types($school_id);
  333. $options = audit_get_approval_options();
  334. // Go through our types, displaying completed or not completed lines...
  335. foreach ($types as $approval_type => $approval_details) {
  336. $approval_title = $approval_details["title"];
  337. $approval_description = $approval_details["description"];
  338. $approval_value = '';
  339. $faculty_id = '';
  340. $posted = 0;
  341. $cur = audit_get_approval_record($student->student_id, $approval_type);
  342. if ($cur) {
  343. $posted = $cur['posted'];
  344. $faculty_id = $cur['faculty_id'];
  345. $approval_value = $cur['approval_value'];
  346. }
  347. $dt = date("m/d/Y", $posted);
  348. $faculty_name = fp_get_faculty_name($faculty_id);
  349. if ($approval_value == "") {
  350. $approval_value = "not_complete";
  351. $dt = $faculty_name = " -- ";
  352. }
  353. $approval_value_desc = $options[$approval_value];
  354. if ($approval_value_desc == "") @$approval_value_desc = $approval_value;
  355. $rtn .= "<tr class='audit-approval-row audit-approval-row-" . $approval_value . "'>";
  356. $rtn .= "
  357. <td><div class='audit-approval-title audit-approval-" . $approval_value . "'>$approval_title</div>
  358. <td class='audit-approval-value audit-approval-desc-" . $approval_value . "'>" . $approval_value_desc . "</td>
  359. <td class='audit-approval-datetime'>" . $dt . "</td>
  360. <td class='audit-approval-faculty'>" . $faculty_name . "</td>";
  361. $rtn .= "
  362. <td>
  363. <a class='approval-edit' href='javascript:popupSmallIframeDialog(\"" . fp_url("audit/popup-edit-approval/$approval_type/$student->student_id") . "\",\"" . t("Edit Approval") . "\",\"\");'><i class='fa fa-pencil'></i> Edit</a>
  364. </td>
  365. ";
  366. $rtn .= "</tr>";
  367. // If the is an approval_description, show it in a new row....
  368. if ($approval_description != "") {
  369. $rtn .= "<tr>
  370. <td colspan='5' class='audit-approval-description audit-approval-description=" . $approval_value . "'><div>$approval_description</div></td>
  371. </tr>";
  372. }
  373. } // foreach types => approval_type
  374. $rtn .= "
  375. </table> <!-- class approvals -->
  376. </td>
  377. </tr>
  378. </table> <!-- class audit-table -->";
  379. $rtn .= "
  380. <hr>
  381. <h2>" . t("Audit Comments") . "</h2>
  382. " . t("These comments will be visible to individuals with access to this tab.") . "
  383. ";
  384. // Add our audit comments form in the page. The extra code is about not making the title show
  385. // up twice.
  386. $temp_title = $GLOBALS["fp_set_title"];
  387. $GLOBALS["fp_set_title"] = ""; // prevent page title from showing up here
  388. $form = fp_render_form("audit_comment_form", "normal", $student->student_id, $user->cwid);
  389. $GLOBALS["fp_set_title"] = $temp_title;
  390. $rtn .= fp_render_c_fieldset($form, t("Click to enter audit comment"), TRUE, 'enter-audit-comment-fs');
  391. $comments = comments_get_comments($student->student_id, FALSE, array("audit private"));
  392. foreach($comments as $comment) {
  393. $delete_link = "";
  394. // Should we present a "delete link" to the user for this comment?
  395. if (user_has_permission("can_delete_own_comments_3_months")) {
  396. // See if this comment is younger than 3 months.
  397. $del_range = strtotime("-3 month");
  398. $then = $comment["posted"];
  399. if ($then > $del_range) {
  400. // We will use the comment module's delete function for this, and tell it to
  401. // redirect back here by setting the destination=audit.
  402. $js_action = 'window.location=FlightPath.settings.basePath + "/comments/delete-comment&current_student_id=' . $student->student_id . '&comment_id=' . $comment['id'] . '&destination=audit";';
  403. $delete_link = fp_get_js_confirm_link(t("Are you sure you wish to delete this comment?\nThis action cannot be undone."), $js_action, "Delete?");
  404. }
  405. }
  406. $rtn .= comments_render_comment($comment, $delete_link);
  407. }
  408. // We wish to add our hidden form, so the approval popup can write its values to this page,
  409. // and then submit them.
  410. $temp_title = $GLOBALS["fp_set_title"];
  411. $GLOBALS["fp_set_title"] = ""; // prevent page title from showing up here
  412. $rtn .= fp_render_form("audit_hidden_approval_form");
  413. $GLOBALS["fp_set_title"] = $temp_title;
  414. watchdog("audit", "display_audit $student->student_id", array());
  415. return $rtn;
  416. }
  417. function audit_comment_form($student_id, $faculty_id) {
  418. $form = array();
  419. $form["student_id"] = array(
  420. "type" => "hidden",
  421. "value" => $student_id,
  422. );
  423. $form["faculty_id"] = array(
  424. "type" => "hidden",
  425. "value" => $faculty_id,
  426. );
  427. $form["comment"] = array(
  428. "type" => "textarea",
  429. );
  430. $form["submit"] = array(
  431. "type" => "submit",
  432. "value" => t("Save"),
  433. );
  434. return $form;
  435. }
  436. function audit_comment_form_submit($form, $form_state) {
  437. global $user, $current_student_id;
  438. $faculty_id = $form_state["values"]["faculty_id"];
  439. $student_id = $form_state["values"]["student_id"];
  440. $type = "audit private";
  441. $comment = trim($form_state["values"]["comment"]);
  442. // Perform the save!
  443. if ($comment) {
  444. db_query("INSERT INTO advising_comments
  445. (student_id, faculty_id, term_id,
  446. comment, posted, access_type)
  447. VALUES
  448. (?, ?, ?, ?, ?, ?)
  449. ", array($student_id, $faculty_id, 0, $comment, time(), $type));
  450. fp_add_message(t("Audit comment saved successfully."));
  451. }
  452. watchdog("audit", "Audit comment saved. student_id:$student_id, comment:$comment");
  453. }
  454. function audit_hidden_approval_form() {
  455. $form = array();
  456. $form["approval_type"] = array(
  457. "type" => "text",
  458. );
  459. $form["approval_student_id"] = array(
  460. "type" => "text",
  461. );
  462. $form["approval_value"] = array(
  463. "type" => "text",
  464. );
  465. $form["approval_comment"] = array(
  466. "type" => "textarea",
  467. );
  468. return $form;
  469. }
  470. function audit_hidden_approval_form_submit($form, $form_state) {
  471. global $user;
  472. $values = $form_state["values"];
  473. $faculty_id = $user->cwid;
  474. $student_id = $values["approval_student_id"];
  475. $approval_type = $values["approval_type"];
  476. $approval_value = $values["approval_value"];
  477. $comment = trim($values["approval_comment"]);
  478. $school_id = db_get_school_id_for_student_id($student_id);
  479. // Check that we have permission to edit the approval for this person?
  480. if (!user_has_permission("edit_audit_approvals") || !audit_can_access_audit($student_id)) {
  481. fp_add_message(t("You do not have permission to edit audit approvals for this student"), "error");
  482. return FALSE;
  483. }
  484. $types = audit_get_approval_types($school_id);
  485. $details = $types[$approval_type];
  486. $approval_type_title = $details["title"];
  487. if ($approval_type_title == "") $approval_type_title = $approval_type;
  488. // Okay, let's save the approval status to our table.
  489. // Begin by deleting what's there for this approval type and student.
  490. db_query("DELETE FROM audit_approvals
  491. WHERE student_id = '?'
  492. AND approval_type = '?' ", $student_id, $approval_type);
  493. // Now, add our values
  494. $now = time();
  495. db_query("INSERT INTO audit_approvals
  496. (student_id, uid, faculty_id, approval_type, approval_value, posted)
  497. VALUES ('?', '?', '?', '?', '?', '?')
  498. ", $student_id, $user->id, $faculty_id, $approval_type, $approval_value, $now);
  499. fp_add_message(t("Approval value has been successfully updated for type %title.", array("%type" => $approval_type, "%title" => $approval_type_title)));
  500. // Also write to our comments table, and include the comment.
  501. //$approval_desc = ($approval_value == "no_approve") ? t("Not approved") : t("Approved");
  502. $options = audit_get_approval_options();
  503. $approval_desc = $options[$approval_value];
  504. if ($approval_desc == "") $approval_desc = $approval_value;
  505. $new_comment = " -- " . t("Automated Audit Comment") . " --<br><br>
  506. " . t("Approval status updated for:") . " <b>$approval_type_title</b>. " . t("New value:") . " <b>$approval_desc</b>.";
  507. if ($comment != "") {
  508. $new_comment .= "<br><br>" . t("Additional comment:") . " <br>-----------<br><em>" . nl2br($comment) . "</em>";
  509. }
  510. $new_values = array(
  511. "student_id" => $student_id,
  512. "faculty_id" => $faculty_id,
  513. "comment" => $new_comment,
  514. );
  515. audit_comment_form_submit(array(), array("values" => $new_values));
  516. }
  517. /**
  518. * Used by the menu to determine if the user can see the Audit tab at all.
  519. *
  520. * Basically, have we selected a student? AND, do we have the correct
  521. * permission?
  522. */
  523. function audit_can_access_audit($student_id = "") {
  524. global $current_student_id, $user;
  525. if ($student_id == "") $student_id = $current_student_id;
  526. // must be logged in first...
  527. if (!user_has_permission("access_logged_in_content")) return FALSE;
  528. if ($student_id != "") {
  529. // yes, a student has been selected. Do we have permission to view audits for THIS student?
  530. if (user_has_permission("view_student_audits") && advise_can_access_view($student_id)) return TRUE;
  531. }
  532. return FALSE;
  533. }
  534. /**
  535. * Implementation of hook_perm
  536. *
  537. */
  538. function audit_perm() {
  539. return array(
  540. "administer_audit" => array(
  541. "title" => t("Administer audit module settings"),
  542. ),
  543. "view_student_audits" => array(
  544. "title" => t("View student audits"),
  545. "description" => t("View the Audit tab for selected student, including audit comments."),
  546. ),
  547. "edit_audit_approvals" => array(
  548. "title" => t("Edit audit approvals"),
  549. "description" => t("Allows user to edit the 'approvals' for a student audit. Ex: faculty or other user types."),
  550. ),
  551. );
  552. }

Functions

Namesort descending Description
audit_can_access_audit Used by the menu to determine if the user can see the Audit tab at all.
audit_comment_form
audit_comment_form_submit
audit_display_audit
audit_get_approval_options Returns a simple array of the available approval options in the popup.
audit_get_approval_record
audit_get_approval_types Return an assoc array of approval types.
audit_hidden_approval_form
audit_hidden_approval_form_submit
audit_menu Implementation of hook_menu
audit_perm Implementation of hook_perm
audit_popup_edit_approval_form This is the actual form that will be used to change an audit approval for a student.
audit_settings_form
audit_settings_form_validate