admin.module

  1. 7.x modules/admin/admin.module
  2. 6.x modules/admin/admin.module
  3. 4.x modules/admin/admin.module
  4. 5.x modules/admin/admin.module

The administrative configurations for FlightPath.

File

modules/admin/admin.module
View source
  1. <?php
  2. /**
  3. * @file
  4. * The administrative configurations for FlightPath.
  5. *
  6. *
  7. */
  8. /**
  9. * Implementation of hook_menu
  10. *
  11. */
  12. function admin_menu() {
  13. $items = array();
  14. $items["admin-tools/admin"] = array(
  15. "title" => "FlightPath Admin Console",
  16. "page_callback" => "admin_display_main",
  17. "access_arguments" => array("can_access_admin"),
  18. "tab_family" => "admin",
  19. "page_settings" => array(
  20. "page_has_search" => FALSE,
  21. "page_banner_is_link" => TRUE,
  22. "page_hide_report_error" => TRUE,
  23. "target" => "_blank",
  24. ),
  25. "type" => MENU_TYPE_TAB,
  26. );
  27. $items["admin/config/urgent-message"] = array(
  28. "title" => "Edit urgent message",
  29. "description" => "Set a message which will be displayed to all users on every page",
  30. "page_callback" => "fp_render_form",
  31. "page_arguments" => array("admin_urgent_message_form", "system_settings"),
  32. "access_arguments" => array("can_edit_urgent_message"),
  33. "page_settings" => array(
  34. "page_has_search" => FALSE,
  35. "page_banner_is_link" => TRUE,
  36. "page_hide_report_error" => TRUE,
  37. "menu_links" => array(
  38. 0 => array(
  39. "text" => "Back to main menu",
  40. "path" => "admin-tools/admin",
  41. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  42. ),
  43. ),
  44. ),
  45. "type" => MENU_TYPE_NORMAL_ITEM,
  46. "tab_parent" => "admin-tools/admin",
  47. );
  48. $items["admin/config/watchdog"] = array(
  49. "title" => "Watchdog (logs)",
  50. "description" => "View log messages from throughout the system",
  51. "page_callback" => "admin_display_watchdog",
  52. "access_arguments" => array("display_watchdog"),
  53. "page_settings" => array(
  54. "page_has_search" => FALSE,
  55. "page_show_title" => TRUE,
  56. "page_banner_is_link" => TRUE,
  57. "page_hide_report_error" => TRUE,
  58. "menu_links" => array(
  59. 0 => array(
  60. "text" => "Back to main menu",
  61. "path" => "admin-tools/admin",
  62. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  63. ),
  64. ),
  65. ),
  66. "type" => MENU_TYPE_NORMAL_ITEM,
  67. "tab_parent" => "admin-tools/admin",
  68. );
  69. $items["admin/config/watchdog/%"] = array(
  70. "title" => "View Watchdog Entry",
  71. "page_callback" => "admin_display_watchdog_entry",
  72. "page_arguments" => array(3),
  73. "access_arguments" => array("display_watchdog"),
  74. "page_settings" => array(
  75. "page_has_search" => FALSE,
  76. "page_show_title" => TRUE,
  77. "page_banner_is_link" => TRUE,
  78. "page_hide_report_error" => TRUE,
  79. "menu_links" => array(
  80. 0 => array(
  81. "text" => "Back to main menu",
  82. "path" => "admin-tools/admin",
  83. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  84. ),
  85. 1 => array(
  86. "text" => "Back to watchdog",
  87. "path" => "admin/config/watchdog",
  88. "query" => "de_catalog_year=%DE_CATALOG_YEAR%&sev_filter=%SEV_FILTER%&page=%PAGE%&type_filter=%TYPE_FILTER%",
  89. ),
  90. ),
  91. ),
  92. "type" => MENU_TYPE_CALLBACK,
  93. "tab_parent" => "admin-tools/admin",
  94. );
  95. $items["admin/duplicate-year"] = array(
  96. "title" => "Duplicate entire catalog year",
  97. "page_callback" => "fp_render_form",
  98. "page_arguments" => array("admin_duplicate_year_form"),
  99. "access_arguments" => array("can_edit_data_entry"),
  100. "page_settings" => array(
  101. "page_has_search" => FALSE,
  102. "page_banner_is_link" => TRUE,
  103. "page_hide_report_error" => TRUE,
  104. "menu_links" => array(
  105. 0 => array(
  106. "text" => "Back to main menu",
  107. "path" => "admin-tools/admin",
  108. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  109. ),
  110. ),
  111. ),
  112. "type" => MENU_TYPE_NORMAL_ITEM,
  113. "tab_parent" => "admin-tools/admin",
  114. );
  115. $items["admin/edit-advising-settings"] = array(
  116. "title" => "Edit advising settings",
  117. "page_callback" => "fp_render_form",
  118. "page_arguments" => array("admin_advising_settings_form", "system_settings"),
  119. "access_arguments" => array("can_edit_advising_settings"),
  120. "page_settings" => array(
  121. "page_has_search" => FALSE,
  122. "page_banner_is_link" => TRUE,
  123. "page_hide_report_error" => TRUE,
  124. "menu_links" => array(
  125. 0 => array(
  126. "text" => "Back to main menu",
  127. "path" => "admin-tools/admin",
  128. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  129. ),
  130. ),
  131. ),
  132. "type" => MENU_TYPE_NORMAL_ITEM,
  133. "tab_parent" => "admin-tools/admin",
  134. );
  135. $items["admin/apply-draft-changes"] = array(
  136. "title" => "Apply draft changes",
  137. "page_callback" => "fp_render_form",
  138. "page_arguments" => array("admin_apply_draft_changes_form"),
  139. "access_arguments" => array("can_apply_draft_changes"),
  140. "page_settings" => array(
  141. "page_has_search" => FALSE,
  142. "page_banner_is_link" => TRUE,
  143. "page_hide_report_error" => TRUE,
  144. "menu_links" => array(
  145. 0 => array(
  146. "text" => "Back to main menu",
  147. "path" => "admin-tools/admin",
  148. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  149. ),
  150. ),
  151. ),
  152. "type" => MENU_TYPE_NORMAL_ITEM,
  153. "tab_parent" => "admin-tools/admin",
  154. );
  155. ///////////////////////////////////////////////////////
  156. ////////////////////// Degree Editing ///////////////////
  157. $items["admin/degrees"] = array(
  158. "title" => "Degrees",
  159. "page_callback" => "admin_display_degrees",
  160. "access_arguments" => array("can_access_data_entry"),
  161. "page_settings" => array(
  162. "page_has_search" => FALSE,
  163. "page_banner_is_link" => TRUE,
  164. "page_hide_report_error" => TRUE,
  165. "menu_links" => array(
  166. 0 => array(
  167. "text" => "Back to main menu",
  168. "path" => "admin-tools/admin",
  169. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  170. ),
  171. ),
  172. ),
  173. "file" => menu_get_module_path("admin") . "/admin.degrees.inc",
  174. "type" => MENU_TYPE_TAB,
  175. "tab_family" => "admin_degrees",
  176. );
  177. $items["admin/degrees/edit-degree"] = array(
  178. "title" => "Edit Degree",
  179. "page_callback" => "admin_display_edit_degree",
  180. "access_arguments" => array("can_edit_data_entry"),
  181. "page_settings" => array(
  182. "page_has_search" => FALSE,
  183. "page_banner_is_link" => TRUE,
  184. "page_hide_report_error" => TRUE,
  185. "menu_links" => array(
  186. 0 => array(
  187. "text" => "Back to main menu",
  188. "path" => "admin-tools/admin",
  189. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  190. ),
  191. 1 => array(
  192. "text" => "Back to Degrees list",
  193. "path" => "admin/degrees",
  194. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  195. ),
  196. ),
  197. ),
  198. "file" => menu_get_module_path("admin") . "/admin.degrees.inc",
  199. "type" => MENU_TYPE_NORMAL_ITEM,
  200. "tab_parent" => "admin/degrees",
  201. );
  202. $items["admin/degrees/handle-edit-degree-submit"] = array(
  203. "page_callback" => "admin_handle_edit_degree_submit",
  204. "access_arguments" => array("can_edit_data_entry"),
  205. "file" => menu_get_module_path("admin") . "/admin.degrees.inc",
  206. "type" => MENU_TYPE_CALLBACK,
  207. );
  208. $items["admin/degrees/popup-add-group"] = array(
  209. "title" => "Add Group",
  210. "page_callback" => "admin_display_degrees_popup_add_group",
  211. "access_arguments" => array("can_edit_data_entry"),
  212. "page_settings" => array(
  213. "page_has_search" => FALSE,
  214. "page_is_popup" => TRUE,
  215. "page_hide_report_error" => TRUE,
  216. ),
  217. "file" => menu_get_module_path("admin") . "/admin.degrees.inc",
  218. "type" => MENU_TYPE_CALLBACK,
  219. );
  220. $items["admin/degrees/add-degree"] = array(
  221. "title" => "Add Degree",
  222. "page_callback" => "fp_render_form",
  223. "page_arguments" => array("admin_add_degree_form"),
  224. "access_arguments" => array("can_edit_data_entry"),
  225. "page_settings" => array(
  226. "page_has_search" => FALSE,
  227. "page_banner_is_link" => TRUE,
  228. "page_hide_report_error" => TRUE,
  229. "menu_links" => array(
  230. 0 => array(
  231. "text" => "Back to main menu",
  232. "path" => "admin-tools/admin",
  233. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  234. ),
  235. 1 => array(
  236. "text" => "Back to Degrees list",
  237. "path" => "admin/degrees",
  238. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  239. ),
  240. ),
  241. ),
  242. "file" => menu_get_module_path("admin") . "/admin.degrees.inc",
  243. "type" => MENU_TYPE_NORMAL_ITEM,
  244. "tab_parent" => "admin/degrees",
  245. );
  246. $items["admin/degrees/copy-degree"] = array(
  247. "title" => "Copy Degree",
  248. "page_callback" => "fp_render_form",
  249. "page_arguments" => array("admin_copy_degree_form"),
  250. "access_arguments" => array("can_edit_data_entry"),
  251. "page_settings" => array(
  252. "page_has_search" => FALSE,
  253. "page_banner_is_link" => TRUE,
  254. "page_hide_report_error" => TRUE,
  255. "menu_links" => array(
  256. 0 => array(
  257. "text" => "Back to main menu",
  258. "path" => "admin-tools/admin",
  259. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  260. ),
  261. 1 => array(
  262. "text" => "Back to Degrees list",
  263. "path" => "admin/degrees",
  264. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  265. ),
  266. ),
  267. ),
  268. "file" => menu_get_module_path("admin") . "/admin.degrees.inc",
  269. "type" => MENU_TYPE_CALLBACK,
  270. "tab_parent" => "admin/degrees",
  271. );
  272. ///////////////////////////////////////////////////////
  273. ////////////////////// Group Editing ///////////////////
  274. $items["admin/groups"] = array(
  275. "title" => "Groups",
  276. "page_callback" => "admin_display_groups",
  277. "access_arguments" => array("can_access_data_entry"),
  278. "page_settings" => array(
  279. "page_has_search" => FALSE,
  280. "page_banner_is_link" => TRUE,
  281. "page_hide_report_error" => TRUE,
  282. "menu_links" => array(
  283. 0 => array(
  284. "text" => "Back to main menu",
  285. "path" => "admin-tools/admin",
  286. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  287. ),
  288. ),
  289. ),
  290. "file" => menu_get_module_path("admin") . "/admin.groups.inc",
  291. "type" => MENU_TYPE_TAB,
  292. "tab_family" => "admin_groups",
  293. );
  294. $items["admin/groups/edit-group"] = array(
  295. "title" => "Edit Group",
  296. "page_callback" => "fp_render_form",
  297. "page_arguments" => array("admin_edit_group_form"),
  298. "access_arguments" => array("can_edit_data_entry"),
  299. "page_settings" => array(
  300. "page_has_search" => FALSE,
  301. "page_banner_is_link" => TRUE,
  302. "page_hide_report_error" => TRUE,
  303. "menu_links" => array(
  304. 0 => array(
  305. "text" => "Back to main menu",
  306. "path" => "admin-tools/admin",
  307. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  308. ),
  309. 1 => array(
  310. "text" => "Back to Groups list",
  311. "path" => "admin/groups",
  312. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  313. ),
  314. ),
  315. ),
  316. "file" => menu_get_module_path("admin") . "/admin.groups.inc",
  317. "type" => MENU_TYPE_NORMAL_ITEM,
  318. "tab_parent" => "admin/groups",
  319. );
  320. $items["admin/groups/popup-select-icon"] = array(
  321. "title" => "Select Icon",
  322. "page_callback" => "admin_display_groups_popup_select_icon",
  323. "access_arguments" => array("can_edit_data_entry"),
  324. "page_settings" => array(
  325. "page_has_search" => FALSE,
  326. "page_is_popup" => TRUE,
  327. "page_hide_report_error" => TRUE,
  328. ),
  329. "file" => menu_get_module_path("admin") . "/admin.groups.inc",
  330. "type" => MENU_TYPE_CALLBACK,
  331. );
  332. $items["admin/groups/popup-edit-definition"] = array(
  333. "title" => "Edit Definition",
  334. "page_callback" => "admin_display_groups_popup_edit_definition",
  335. "access_arguments" => array("can_edit_data_entry"),
  336. "page_settings" => array(
  337. "page_has_search" => FALSE,
  338. "page_is_popup" => TRUE,
  339. "page_hide_report_error" => TRUE,
  340. ),
  341. "file" => menu_get_module_path("admin") . "/admin.groups.inc",
  342. "type" => MENU_TYPE_CALLBACK,
  343. );
  344. $items["admin/groups/popup-show-group-use"] = array(
  345. "title" => "Group Use",
  346. "page_callback" => "admin_display_groups_popup_show_group_use",
  347. "access_arguments" => array("can_edit_data_entry"),
  348. "page_settings" => array(
  349. "page_has_search" => FALSE,
  350. "page_is_popup" => TRUE,
  351. "page_hide_report_error" => TRUE,
  352. ),
  353. "file" => menu_get_module_path("admin") . "/admin.groups.inc",
  354. "type" => MENU_TYPE_CALLBACK,
  355. );
  356. $items["admin/groups/process-all-definitions"] = array(
  357. "title" => "Process all Definitions",
  358. "page_callback" => "fp_render_form",
  359. "page_arguments" => array("admin_process_all_definitions_form"),
  360. "access_arguments" => array("can_edit_data_entry"),
  361. "page_settings" => array(
  362. "page_has_search" => FALSE,
  363. "page_banner_is_link" => TRUE,
  364. "page_hide_report_error" => TRUE,
  365. "menu_links" => array(
  366. 0 => array(
  367. "text" => "Back to main menu",
  368. "path" => "admin-tools/admin",
  369. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  370. ),
  371. 1 => array(
  372. "text" => "Back to Groups list",
  373. "path" => "admin/groups",
  374. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  375. ),
  376. ),
  377. ),
  378. "file" => menu_get_module_path("admin") . "/admin.groups.inc",
  379. "type" => MENU_TYPE_NORMAL_ITEM,
  380. "tab_parent" => "admin/groups",
  381. );
  382. /////////////////////////////////////////////////
  383. /////////////////// Courses editing ////////////////
  384. $items["admin/courses"] = array(
  385. "title" => "Courses",
  386. "page_callback" => "admin_display_courses",
  387. "access_arguments" => array("can_access_data_entry"),
  388. "page_settings" => array(
  389. "page_has_search" => FALSE,
  390. "page_banner_is_link" => TRUE,
  391. "page_hide_report_error" => TRUE,
  392. "menu_links" => array(
  393. 0 => array(
  394. "text" => "Back to main menu",
  395. "path" => "admin-tools/admin",
  396. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  397. ),
  398. ),
  399. ),
  400. "file" => menu_get_module_path("admin") . "/admin.courses.inc",
  401. "type" => MENU_TYPE_TAB,
  402. "tab_family" => "admin_courses",
  403. );
  404. $items["admin/courses/edit-course"] = array(
  405. "title" => "Edit Course",
  406. "page_callback" => "fp_render_form",
  407. "page_arguments" => array("admin_edit_course_form"),
  408. "access_arguments" => array("can_edit_data_entry"),
  409. "page_settings" => array(
  410. "page_has_search" => FALSE,
  411. "page_banner_is_link" => TRUE,
  412. "page_hide_report_error" => TRUE,
  413. "menu_links" => array(
  414. 0 => array(
  415. "text" => "Back to main menu",
  416. "path" => "admin-tools/admin",
  417. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  418. ),
  419. 1 => array(
  420. "text" => "Back to Courses list",
  421. "path" => "admin/courses",
  422. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  423. ),
  424. ),
  425. ),
  426. "file" => menu_get_module_path("admin") . "/admin.courses.inc",
  427. "type" => MENU_TYPE_NORMAL_ITEM,
  428. "tab_parent" => "admin/courses",
  429. );
  430. return $items;
  431. }
  432. /**
  433. * This form will allow the user to duplicate an entire year's worth of data to a new
  434. * catalog year.
  435. *
  436. */
  437. function admin_duplicate_year_form() {
  438. $form = array();
  439. $form["mark" . $m++] = array(
  440. "value" => "<p>" . t("This form will allow you to duplicate an entire year's worth of data
  441. (courses, degrees, groups) into a new year. This is used to create a new
  442. year of data, based on the previous year, for example. <b>It will completely
  443. delete the 'destination' year data, if it already exists!</b> Use carefully.
  444. <br><br>
  445. The new year will be placed in DRAFT, and will not be visible in FlightPath
  446. until draft changes are applied.
  447. <br><br>
  448. <u>It would be wise</u> to back up your database before proceeding.") . "</p><hr>",
  449. );
  450. $form["source_year"] = array(
  451. "type" => "textfield",
  452. "label" => t("Source year:"),
  453. "size" => 10,
  454. "required" => TRUE,
  455. "description" => t("Enter the 4-digit source year you are copying FROM. For example,
  456. 2007. If you are copying from '2007-2008' then just enter
  457. 2007."),
  458. );
  459. $form["destination_year"] = array(
  460. "type" => "textfield",
  461. "label" => t("Destination year:"),
  462. "size" => 10,
  463. "required" => TRUE,
  464. "description" => t("Enter the 4-digit source year you are copying TO. <b><u>If this year
  465. all ready exists in the system, all data for this year will be DELETED.</u></b>
  466. If you are copying to '2009-2010' then just enter
  467. 2009."),
  468. );
  469. $form["passcode"] = array(
  470. "type" => "password",
  471. "label" => t("For added security, you must enter the Apply Draft Changes password:"),
  472. "required" => TRUE,
  473. "description" => t("This is a password set up in FlightPath's settings, to provide an extra layer
  474. of security for this powerful action. Draft changes will not actually be applied,
  475. this is simply used as an added layer of security."),
  476. );
  477. $form["submit"] = array(
  478. "type" => "submit",
  479. "value" => t("Submit"),
  480. "description" => t("This action may take several minutes to complete! Click only ONCE!"),
  481. "prefix" => "<hr>",
  482. );
  483. return $form;
  484. }
  485. /**
  486. * This function should perform the actual copy of data!
  487. *
  488. * @param unknown_type $form
  489. * @param unknown_type $form_state
  490. */
  491. function admin_duplicate_year_form_submit($form, $form_state) {
  492. $values = $form_state["values"];
  493. // Check to make sure they entered the transfer passcode correctly.
  494. $db = get_global_database_handler();
  495. if ($values["passcode"] != variable_get("admin_transfer_passcode", "h24897Ewujflnb7 wy2896432hke w490ukj")) {
  496. form_error("passcode", t("Error! The password you entered is not correct. Check with the FlightPath administrator
  497. (or check the admin settings pages) to learn the password."));
  498. return;
  499. }
  500. // Okay, we made it this far, let's proceed with the copy!
  501. $new_year = $values["destination_year"];
  502. $old_year = $values["source_year"];
  503. /////////////////////////////////////////////////////////////////////
  504. // We must first begin by deleting any entries for the new_year
  505. // from our tables. This is because we may have to run the parser
  506. // more than once while debugging and such.
  507. $res = db_query("DELETE FROM draft_courses WHERE `catalog_year`='$new_year' ");
  508. $res = db_query("DELETE FROM draft_degree_tracks WHERE `catalog_year`='$new_year' ");
  509. // For degrees, we first need to select all of the new_year degrees.
  510. $res = db_query("SELECT * FROM draft_degrees WHERE `catalog_year`='$new_year' ");
  511. while ($cur = db_fetch_array($res)) {
  512. $res2 = db_query("DELETE FROM draft_degree_requirements WHERE `degree_id`='{$cur["degree_id"]}' ");
  513. }
  514. $res = db_query("DELETE FROM draft_degrees WHERE `catalog_year`='$new_year' ");
  515. // For groups, begin by selecting all the groups in that year...
  516. $res = db_query("SELECT * FROM draft_groups WHERE `catalog_year`='$new_year' ");
  517. while ($cur = db_fetch_array($res))
  518. {
  519. // Now, select all the requirements and see if there are any sub groups...
  520. $res2 = db_query("SELECT * FROM draft_group_requirements WHERE `group_id`='{$cur["group_id"]}' ");
  521. while ($cur2 = db_fetch_array($res2))
  522. {
  523. if ($cur2["child_group_id"] > 0)
  524. {
  525. // Delete the child group.
  526. $res3 = db_query("DELETE FROM draft_group_requirements WHERE `group_id`='{$cur2["child_group_id"]}' ");
  527. }
  528. }
  529. // Now, delete the original requirement.
  530. $res3 = db_query("DELETE FROM draft_group_requirements WHERE `group_id`='{$cur["group_id"]}' ");
  531. }
  532. $res = db_query("DELETE FROM draft_groups WHERE `catalog_year`='$new_year' ");
  533. //////////////////////////////////////////////////////////////////////////
  534. // Okay, we have deleted any possible old entries for the new year.
  535. /////////////////////////////////////////////////////////////////////////
  536. // Our first step is to copy all of the courses from the old_year to the new_year.
  537. $res = db_query("SELECT * FROM draft_courses WHERE `catalog_year`='$old_year' ");
  538. while ($cur = db_fetch_array($res))
  539. {
  540. extract($cur, 3, "db");
  541. $course = new Course($db_course_id, false, $db, false, $old_year);
  542. $course->subject_id = $db_subject_id;
  543. $course->course_num = $db_course_num;
  544. $course->db_exclude = $db_exclude;
  545. // Now, duplicate it for the new_year.
  546. $db->duplicate_course_for_year($course, $new_year);
  547. }
  548. $group_id_array = array();
  549. $subgroup_id_array = array();
  550. //////////////////////////////////////////////////////////////////////////
  551. // Now, let's copy over the groups.
  552. $res = db_query("SELECT * FROM draft_groups WHERE `catalog_year`='$old_year' ");
  553. while ($cur = db_fetch_array($res))
  554. {
  555. extract($cur, 3, "db");
  556. // First, let's request a new group ID for this new group.
  557. $new_group_id = $db->request_new_group_id();
  558. $group_id_array[$db_group_id] = $new_group_id;
  559. //$db_data_entry_comment = mysql_real_escape_string($db_data_entry_comment);
  560. // Now, let's insert this top-level group back into the table
  561. // as the new_year, with the new_group_id.
  562. $query = "INSERT INTO draft_groups(`group_id`,`group_name`,
  563. `title`,`definition`,`icon_filename`,`catalog_year`,
  564. `priority`,`delete_flag`,`data_entry_comment`)
  565. VALUES ('?','?','?','?','?','?','?','?','?') ";
  566. $res2 = db_query($query, $new_group_id,$db_group_name,$db_title,
  567. $db_definition,$db_icon_filename,$new_year,
  568. $db_priority,$db_delete_flag,$db_data_entry_comment);
  569. // Okay, now we need to go through the requirements for the group, and copy
  570. // those over to the new_year.
  571. $res3 = db_query("SELECT * FROM draft_group_requirements
  572. WHERE `group_id`='$db_group_id' ");
  573. while($cur3 = db_fetch_array($res3))
  574. {
  575. extract($cur3, 3, "db3");
  576. $child_group_id = 0;
  577. // Was there a child_group (a branch)? If so, we need to copy that
  578. // over too, with a new child_group_id.
  579. if ($db3_child_group_id > 0)
  580. {
  581. // First, create the child group...
  582. $new_sub_group_id = $db->request_new_group_id();
  583. $subgroup_id_array[$db3_child_group_id] = $new_sub_group_id;
  584. $res4 = db_query("SELECT * FROM draft_group_requirements
  585. WHERE `group_id`='$db3_child_group_id' ");
  586. while($cur4 = db_fetch_array($res4))
  587. {
  588. extract($cur4, 3, "db4");
  589. $res5 = db_query("INSERT INTO draft_group_requirements
  590. (`group_id`,`course_id`,`course_min_grade`,
  591. `course_repeats`,`data_entry_value`)
  592. VALUES ('?','?','?','?','?') ",
  593. $new_sub_group_id,$db4_course_id,
  594. $db4_course_min_grade,$db4_course_repeats,
  595. $db4_data_entry_value);
  596. }
  597. // Now, add the replace the db3_child_group_id with this new id
  598. // so it will get added as a requirement.
  599. $child_group_id = $new_sub_group_id;
  600. }
  601. // Add the row into the table...
  602. $res5 = db_query("INSERT INTO draft_group_requirements
  603. (`group_id`,`course_id`,`course_min_grade`,
  604. `course_repeats`,`data_entry_value`,`child_group_id`)
  605. VALUES ('?','?','?','?','?','?') ",
  606. $new_group_id,$db3_course_id,
  607. $db3_course_min_grade,$db3_course_repeats,
  608. $db3_data_entry_value,$child_group_id);
  609. }
  610. }
  611. /////////////////////////////////////////////////////////////////////
  612. // Now, on to transfering the degrees.
  613. // We will have to use the groupIDArray we constructed earlier, which
  614. // looks like $arr[old_id] = new_id.
  615. // Do the tracks first, since they are easier and straight forward...
  616. $res = db_query("SELECT * FROM draft_degree_tracks WHERE `catalog_year`='$old_year' ");
  617. while ($cur = db_fetch_array($res))
  618. {
  619. extract($cur, 3, "db");
  620. $res2 = db_query("INSERT INTO draft_degree_tracks
  621. (`catalog_year`,`major_code`,`track_code`,`track_title`,
  622. `track_short_title`,`track_description`)
  623. VALUES
  624. ('?','?','?','?','?','?') ",
  625. $new_year,$db_major_code,$db_track_code,$db_track_title,
  626. $db_track_short_title,$db_track_description);
  627. }
  628. // Now, let's do the degrees themselves.
  629. $res = db_query("SELECT * FROM draft_degrees WHERE `catalog_year`='$old_year' ");
  630. while ($cur = db_fetch_array($res))
  631. {
  632. extract($cur, 3, "db");
  633. $new_degree_id = $db->request_new_degree_id();
  634. // add in the top-level degree to the table.
  635. $res2 = db_query("INSERT INTO draft_degrees
  636. (`degree_id`,`major_code`,`degree_type`,`title`,
  637. `semester_titles_csv`,`catalog_year`,`exclude`,`degree_class`,`public_note`)
  638. VALUES
  639. ('?','?','?','?','?','?','?','?','?')
  640. ", $new_degree_id,$db_major_code,$db_degree_type,$db_title,
  641. $db_semester_titles_csv,$new_year,$db_exclude, $db_degree_class, $db_public_note);
  642. // now, pull out all of the degree_requirements.
  643. $res3 = db_query("SELECT * FROM draft_degree_requirements
  644. WHERE `degree_id`='$db_degree_id' ");
  645. while($cur3 = db_fetch_array($res3))
  646. {
  647. extract($cur3, 3, "db3");
  648. // If there is a required group, we must convert it to the
  649. // new groupID !
  650. $required_group_id = $db3_group_id;
  651. if ($db3_group_id > 0)
  652. {
  653. $required_group_id = $group_id_array[$db3_group_id];
  654. if ($required_group_id < 1 || $required_group_id == "")
  655. {
  656. die("could not find group new group for $old_year $db3_group_id !");
  657. }
  658. }
  659. $res4 = db_query("INSERT INTO draft_degree_requirements
  660. (`degree_id`,`semester_num`,`group_id`,`group_requirement_type`,
  661. `group_hours_required`,`group_min_grade`,`course_id`,
  662. `course_min_grade`,`course_requirement_type`,`data_entry_value`)
  663. VALUES
  664. ('?','?','?','?','?','?','?','?','?','?')
  665. ", $new_degree_id,$db3_semester_num,$required_group_id,$db3_group_requirement_type,
  666. $db3_group_hours_required,$db3_group_min_grade,$db3_course_id,
  667. $db3_course_min_grade,$db3_course_requirement_type,$db3_data_entry_value);
  668. }
  669. }
  670. fp_add_message(t("The copy operation is now completed. You may view the new year
  671. by using the Data Entry links on the admin main menu. Remember, you must
  672. apply draft changes before they will be visible in FlightPath."));
  673. }
  674. /**
  675. * This is a systems settings form, which lets
  676. * the user edit advising variabled for FlightPath.
  677. */
  678. function admin_advising_settings_form() {
  679. $form = array();
  680. $settings = fp_get_system_settings();
  681. $mark = "";
  682. // TODO: This needs to become genericized! If it can't be, it should just be taken out.
  683. $sems = array(40,41, 60,81,82);
  684. for($t = $settings["current_catalog_year"]; $t <= $settings["current_catalog_year"] + 2; $t++) {
  685. $mark .= "<div style='padding-left: 15px;'>";
  686. foreach($sems as $sm) {
  687. $try_year = $t . $sm;
  688. $course = new Course();
  689. $course->term_id = $try_year;
  690. $mark .= "" . $course->get_term_description(true) . ": <b>$course->term_id</b>, &nbsp; &nbsp; &nbsp;";
  691. }
  692. $mark .= "</div>";
  693. }
  694. $form["mark" . $m++] = array(
  695. "type" => "markup",
  696. "value" => t("Term ID Quick Reference:") . $mark,
  697. );
  698. $form["available_advising_term_ids"] = array(
  699. "type" => "textfield",
  700. "label" => t("Available advising term ids"),
  701. "value" => variable_get("available_advising_term_ids", ""),
  702. "description" => t("Separate by commas. Ex: 200940, 200941, 200960. Make sure to enter
  703. in the order that they should appear in FlightPath."),
  704. );
  705. $form["advising_term_id"] = array(
  706. "type" => "textfield",
  707. "label" => t("Default advising term id"),
  708. "value" => variable_get("advising_term_id", ""),
  709. "description" => t("Of the available term ids above, this is the default that FlightPath
  710. is set to when an advisor logs in. Ex: 200940."),
  711. );
  712. $form["current_catalog_year"] = array(
  713. "type" => "textfield",
  714. "size" => 10,
  715. "label" => t("Current catalog year"),
  716. "value" => variable_get("current_catalog_year", ""),
  717. "description" => t("This is the year which What If loads degrees from, as well as other important functions.
  718. Only change this once you have fully loaded a new catalog year."),
  719. );
  720. $form["current_draft_catalog_year"] = array(
  721. "type" => "textfield",
  722. "size" => 10,
  723. "label" => t("Current DRAFT catalog year"),
  724. "value" => variable_get("current_draft_catalog_year", ""),
  725. "description" => t("While in Draft mode, this is the year which Blank Degree Search loads degrees from. What If
  726. mode will always use the Current catalog year, set above.
  727. You may change this while working on a new catalog. It will not affect any other
  728. users of the system. While not working on a new catalog, set this
  729. to the same as the Current catalog year."),
  730. );
  731. $form["not_released_grades_terms"] = array(
  732. "type" => "textfield",
  733. "label" => t("NOT released grades terms"),
  734. "value" => variable_get("not_released_grades_terms", ""),
  735. "description" => t("Enter the term_id's, separated by commas,
  736. which are NOT released and should NOT be visible to either advisors or students.
  737. Coures in these terms will only show midterm grades or no grades at all.
  738. Ex: 201240, 201240:S1") . "<br>" . t("If left blank, grades will be visible to
  739. students and advisors as soon as they appear in the database."),
  740. );
  741. return $form;
  742. }
  743. /**
  744. * Convienence function to get semester's default regular name.
  745. */
  746. function admin_get_semester_name($semester_num) {
  747. $semester = new Semester($semester_num);
  748. $title = $semester->title;
  749. /**
  750. $ar = array(t("Freshman Year"), t("Sophomore Year"), t("Junior Year"), t("Senior Year"));
  751. $s = $ar[$semester_num];
  752. if ($s == "")
  753. {
  754. $s = t("Year") . " " . ($semester_num + 1);
  755. }
  756. */
  757. return $title;
  758. }
  759. /**
  760. * This form lets the user apply draft changes (if they can supply the passcode)
  761. */
  762. function admin_apply_draft_changes_form() {
  763. $form = array();
  764. $form["mark" . $m++] = array(
  765. "type" => "markup",
  766. "value" => t("You can use this form to apply your draft changes to the production database, making changes
  767. to degrees, courses, and groups visible to all users of the system."),
  768. );
  769. $form["passcode"] = array(
  770. "type" => "password",
  771. "label" => t("For added security, you must enter the Apply Draft Changes password:"),
  772. "required" => TRUE,
  773. "description" => t("This is a password set up in FlightPath's settings, to provide an extra layer
  774. of security for this powerful action."),
  775. );
  776. $form["submit"] = array(
  777. "type" => "submit",
  778. "value" => t("Submit"),
  779. "description" => t("This action may take several seconds to complete! Click only ONCE!"),
  780. "prefix" => "<hr>",
  781. );
  782. return $form;
  783. }
  784. /**
  785. * Handles the actual moving of draft courses into production.
  786. */
  787. function admin_apply_draft_changes_form_submit($form, $form_submit) {
  788. $values = $form_submit["values"];
  789. $db = get_global_database_handler();
  790. $de_catalog_year = admin_get_de_catalog_year();
  791. // Check to make sure they entered the transfer passcode correctly.
  792. if ($values["passcode"] != variable_get("admin_transfer_passcode", "h24897Ewujflnb7 wy2896432hke w490ukj")) {
  793. form_error("passcode", t("Error! The password you entered is not correct. Check with the FlightPath administrator
  794. (or check the admin settings pages) to learn the password."));
  795. return;
  796. }
  797. // First, set maintenance mode...
  798. variable_set("maintenance_mode", TRUE);
  799. // Okay, so what we gotta do is truncate the production tables,
  800. // then copy the draft tables in.
  801. $table_array = array(
  802. "courses",
  803. "degree_requirements",
  804. "degree_tracks",
  805. "degrees",
  806. "group_requirements",
  807. "groups",
  808. );
  809. foreach($table_array as $table_name) {
  810. $draft_table_name = "draft_$table_name";
  811. // First, truncate existing...
  812. $query = "truncate table $table_name";
  813. $res = db_query($query);
  814. // Now, copy in draft changes...
  815. $query = "INSERT INTO $table_name
  816. SELECT * FROM $draft_table_name ";
  817. $res = db_query($query);
  818. }
  819. $db2 = new DatabaseHandler();
  820. // Now, we need to go through the draft_instructions table,
  821. // and perform each instruction one at a time.
  822. $res = db_query("SELECT * FROM draft_instructions
  823. ORDER BY `id` ");
  824. while($cur = db_fetch_array($res))
  825. {
  826. $instruction = trim($cur["instruction"]);
  827. $temp = explode(",",$instruction);
  828. if (trim($temp[0]) == "update_course_id") {
  829. $db2->update_course_id(trim($temp[1]), trim($temp[2]));
  830. }
  831. if (trim($temp[0]) == "update_course_requirement_from_name") {
  832. $db2->update_course_requirement_from_name(trim($temp[1]), trim($temp[2]), trim($temp[3]));
  833. }
  834. }
  835. // Once this is done, truncate the draft_instructions table.
  836. $res = db_query("TRUNCATE TABLE draft_instructions");
  837. // And we are done! Set maintenance mode back to none
  838. variable_set("maintenance_mode", FALSE);
  839. // Send emails to notify programmers...
  840. $notify = variable_get("notify_apply_draft_changes_email_address", "");
  841. if ($notify != "") {
  842. mail($notify, "FlightPath Apply Draft Changes", "Someone has applied draft changes to FlightPath, which updated degree plans, groups, and courses.");
  843. }
  844. fp_add_message(t("Successfully updated the production database with draft changes. Your changes are now live and visible on production for all users."));
  845. watchdog("admin", "Draft changes applied.");
  846. }
  847. /**
  848. * Get the "de_catalog_year" from the REQUEST.
  849. * If it's not there or invalid, pull it from our system settings.
  850. */
  851. function admin_get_de_catalog_year($bool_set_earliest_if_blank = TRUE) {
  852. $settings = fp_get_system_settings();
  853. $de_catalog_year = $_REQUEST["de_catalog_year"];
  854. if ($bool_set_earliest_if_blank) {
  855. if (!$de_catalog_year || $de_catalog_year < $settings["earliest_catalog_year"]) {
  856. $de_catalog_year = $settings["earliest_catalog_year"];
  857. }
  858. }
  859. return $de_catalog_year;
  860. }
  861. /**
  862. * This is an implementation of hook_menu_handle_replacement_pattern.
  863. * It will search for and replace replacement patterns which we are aware of it in $str.
  864. */
  865. function admin_menu_handle_replacement_pattern($str) {
  866. if (strpos($str, "%DE_CATALOG_YEAR%") !== 0) {
  867. // It contains this replacement pattern!
  868. $str = str_replace("%DE_CATALOG_YEAR%", admin_get_de_catalog_year(), $str);
  869. }
  870. if (strpos($str, "%SEV_FILTER%") !== 0) {
  871. // It contains this replacement pattern!
  872. $str = str_replace("%SEV_FILTER%", $_GET["sev_filter"], $str);
  873. }
  874. if (strpos($str, "%TYPE_FILTER%") !== 0) {
  875. // It contains this replacement pattern!
  876. $str = str_replace("%TYPE_FILTER%", $_GET["type_filter"], $str);
  877. }
  878. if (strpos($str, "%PAGE%") !== 0) {
  879. // It contains this replacement pattern!
  880. $str = str_replace("%PAGE%", $_GET["page"], $str);
  881. }
  882. return $str;
  883. }
  884. function admin_perm() {
  885. return array(
  886. "can_access_admin" => array(
  887. "title" => t("Access administrative console"),
  888. "description" => t("This is a powerful permission! This allows a
  889. user to access the 'admin console' for FlightPath."),
  890. ),
  891. "can_edit_urgent_message" => array(
  892. "title" => t("Edit urgent message"),
  893. "description" => t("The user may edit the 'Urgent Message' which appears at the top of every page, if set."),
  894. ),
  895. "can_access_data_entry" => array(
  896. "title" => t("Access Data Entry"),
  897. "description" => t("The user can access (view) the data-entry portion of the admin console. Degree plans, groups, and courses."),
  898. ),
  899. "can_edit_data_entry" => array(
  900. "title" => t("Edit Data Entry"),
  901. "description" => t("This is a powerful permission! The user can edit degree plans, groups, and courses."),
  902. ),
  903. "can_view_advanced" => array(
  904. "title" => t("View advanced"),
  905. "description" => t("The user may see advanced information on-screen, for example, internal ID numbers for degrees and courses."),
  906. ),
  907. "can_apply_draft_changes" => array(
  908. "title" => t("Apply draft changes"),
  909. "description" => t("The user may move draft changes into production."),
  910. ),
  911. "can_edit_advising_settings" => array(
  912. "title" => t("Edit advising settings"),
  913. "description" => t("The user may edit advising settings, like available term IDs and the current catalog year."),
  914. ),
  915. "display_watchdog" => array(
  916. "title" => t("View watchdog (log) entries"),
  917. "description" => t("The user may view the recent watchdog log entries. This represents a security concern, so give this only to trusted users."),
  918. ),
  919. );
  920. }
  921. /**
  922. * Meant to be fed into "fp_system_settings_form()", this function
  923. * returns an array which will automatically save values to our "variables" table.
  924. */
  925. function admin_urgent_message_form() {
  926. $form = array();
  927. $form["mark" . $m++] = array(
  928. "type" => "markup",
  929. "value" => "<p>" . t("Any message you enter here will be displayed at the top of every page in the system.
  930. This is used to alert users that the system is about to be taken offline, or any other urgently-needed information.") . "</p>
  931. <p>" . t("To delete this message, simple delete all the text in the box and save.") . "</p>",
  932. );
  933. $form["urgent_msg"] = array(
  934. "type" => "textarea",
  935. "label" => "Urgent message:",
  936. "value" => variable_get("urgent_msg", ""),
  937. );
  938. return $form;
  939. }
  940. /**
  941. * Display the details of a particular watchdog entry, specified by its table id.
  942. */
  943. function admin_display_watchdog_entry($wid) {
  944. $rtn = "";
  945. fp_add_css(fp_get_module_path("admin") . '/css/admin.css');
  946. $severity_array = array(
  947. 5 => "notice",
  948. 1 => "alert",
  949. 3 => "error",
  950. 7 => "debug",
  951. );
  952. $res = db_query("SELECT * FROM watchdog WHERE wid = '?' ", $wid);
  953. $cur = db_fetch_object($res);
  954. $msg = t($cur->message, unserialize($cur->variables));
  955. $severity = $severity_array[$cur->severity];
  956. $when = format_date($cur->timestamp, "short");
  957. // Display
  958. $rtn .= "
  959. <br>
  960. <div class='watchdog-entry'>
  961. <div class='watchdog-field'>
  962. <label>ID:</label>
  963. $cur->wid
  964. </div>
  965. <div class='watchdog-field'>
  966. <label>Type:</label>
  967. $cur->type
  968. </div>
  969. <div class='watchdog-field'>
  970. <label>Time:</label>
  971. $when ($cur->timestamp)
  972. </div>
  973. <div class='watchdog-field'>
  974. <label>Severity:</label>
  975. $severity
  976. </div>
  977. <div class='watchdog-field'>
  978. <label>User:</label>
  979. $cur->user_name | id: $cur->user_id | cwid: $cur->cwid | is_student: $cur->is_student | is_faculty: $cur->is_faculty
  980. </div>
  981. <div class='watchdog-field'>
  982. <label>IP:</label>
  983. $cur->ip
  984. </div>
  985. <div class='watchdog-field'>
  986. <label>Location:</label>
  987. $cur->location
  988. </div>
  989. <div class='watchdog-field'>
  990. <label>Ref:</label>
  991. $cur->referer
  992. </div>
  993. <hr>
  994. <div class='watchdog-field'>
  995. <label class='block'>Message:</label>
  996. $msg
  997. </div>
  998. <div class='watchdog-field'>
  999. <label class='block'>Extra:</label>
  1000. $cur->extra_data
  1001. </div>
  1002. </div>
  1003. ";
  1004. return $rtn;
  1005. }
  1006. /**
  1007. * Displays recent watchdog entries, from the watchdog table
  1008. *
  1009. */
  1010. function admin_display_watchdog() {
  1011. fp_add_css(fp_get_module_path("admin") . '/css/admin.css');
  1012. $rtn = "";
  1013. $rtn .= "<p>View recent watchdog entries</p>";
  1014. $severity_array = array(
  1015. 5 => "notice",
  1016. 1 => "alert",
  1017. 3 => "error",
  1018. 7 => "debug",
  1019. );
  1020. $results_per_page = 50;
  1021. $type_line = $severity_line = $limit_start = "";
  1022. $sev_filter = $_GET["sev_filter"];
  1023. $type_filter = $_GET["type_filter"];
  1024. $page = $_GET["page"];
  1025. $limit_start = 0;
  1026. if ($page != "" && is_numeric($page)) {
  1027. $limit_start = $results_per_page * ($page - 1);
  1028. }
  1029. else {
  1030. $page = 1;
  1031. }
  1032. // Filters:
  1033. $rtn .= "<form method='GET' action='" . fp_url("admin/config/watchdog") . "' class='watchdog-filters'>
  1034. ";
  1035. $rtn .= "Filter by:
  1036. <span class='type-filter'>
  1037. Type:
  1038. <select name='type_filter'>
  1039. <option value=''>-Any-</option>";
  1040. $res = db_query("SELECT distinct(type) as type FROM watchdog ORDER BY type");
  1041. while ($cur = db_fetch_object($res)) {
  1042. $sel = ($type_filter == $cur->type) ? "selected" : "";
  1043. $rtn .= "<option value='$cur->type' $sel>$cur->type</option>";
  1044. }
  1045. $rtn .= "</select>
  1046. </span>";
  1047. $rtn .= "
  1048. <span class='severity-filter'>
  1049. Severity:
  1050. <select name='sev_filter'>
  1051. <option value=''>-Any-</option>";
  1052. foreach ($severity_array as $key => $value) {
  1053. $sel = "";
  1054. if ($sev_filter == $key) $sel = "selected";
  1055. $rtn .= "<option value='$key' $sel>$value</option>";
  1056. }
  1057. $rtn .= "</select>
  1058. </span>";
  1059. $rtn .= "<input type='submit' value='-&gt;'>";
  1060. $rtn .= "</form>";
  1061. if ($_GET["sev_filter"] != "") {
  1062. $severity_line = " AND severity = '" . mysql_real_escape_string($_GET["sev_filter"]) . "' ";
  1063. }
  1064. if ($_GET["type_filter"] != "") {
  1065. $type_line = " AND type = '" . mysql_real_escape_string($_GET["type_filter"]) . "' ";
  1066. }
  1067. $rtn .= "<table class='watchdog-table' cellspacing='0' cellpadding='4'>
  1068. <tr>
  1069. <th>ID</th>
  1070. <th>When</th>
  1071. <th>Type</th>
  1072. <th>Msg</th>
  1073. <th>User</th>
  1074. </tr>";
  1075. // Okay, let's display the recent watchdog entries.
  1076. $query = "SELECT * FROM watchdog
  1077. WHERE 1
  1078. $type_line
  1079. $severity_line
  1080. ORDER BY wid DESC
  1081. ";
  1082. $res = db_query($query . " LIMIT $limit_start, $results_per_page");
  1083. while ($cur = db_fetch_object($res)) {
  1084. $pol = ($pol == "even") ? "odd" : "even";
  1085. $o_msg = t($cur->message, unserialize($cur->variables));
  1086. $o_type = $cur->type;
  1087. // shorten msg if necessary
  1088. $msg = substr($o_msg, 0, 120);
  1089. if ($msg != $o_msg) {
  1090. $msg = trim($msg) . "...";
  1091. }
  1092. $type = substr($o_type, 0, 15);
  1093. if ($type != $o_type) {
  1094. $type = trim($type) . "...";
  1095. }
  1096. $severity = $severity_array[$cur->severity];
  1097. $when = format_date($cur->timestamp, "short");
  1098. $rtn .= "
  1099. <tr class='row-$pol row-$severity'>
  1100. <td valign='top'>" . l($cur->wid, "admin/config/watchdog/$cur->wid", "sev_filter=$sev_filter&type_filter=$type_filter&page=$page") . "</td>
  1101. <td valign='top'>$when</td>
  1102. <td valign='top'>$type</td>
  1103. <td valign='top'>$msg</td>
  1104. <td valign='top'>$cur->user_name</td>
  1105. </tr>
  1106. ";
  1107. }
  1108. $rtn .= "</table>";
  1109. // Now, do the page
  1110. // Figure out the total number of results
  1111. $total = db_result(db_query("SELECT count(wid) as count
  1112. FROM watchdog WHERE 1 $type_line $severity_line "));
  1113. // Now, divide by the number of results per page.
  1114. $pages = ceil($total / $results_per_page);
  1115. $base_query = "sev_filter=$sev_filter&type_filter=$type_filter";
  1116. $rtn .= "<div class='fp-pager'>";
  1117. if ($page > 1) {
  1118. $rtn .= "<span class='pager-link pager-first'>" . l("&laquo; first", "admin/config/watchdog", $base_query . "&page=1") . "</span>";
  1119. $rtn .= "<span class='pager-link pager-prev'>" . l("&lt; prev", "admin/config/watchdog", $base_query . "&page=" . ($page - 1)) . "</span>";
  1120. }
  1121. else {
  1122. $rtn .= "<span class='pager-link pager-first'>&laquo; first</span>";
  1123. $rtn .= "<span class='pager-link pager-prev'>&lt; prev</span>";
  1124. }
  1125. // page numbers here
  1126. // Let's get the previous X page numbers, and next X (if possible)
  1127. $start_page_num = $page - 5;
  1128. if ($start_page_num < 1) $start_page_num = 1;
  1129. $end_page_num = $page + 5;
  1130. if ($end_page_num > $pages) $end_page_num = $pages;
  1131. if ($start_page_num > 1) {
  1132. $rtn .= "<span class='pager-elip'>...</span>";
  1133. }
  1134. for ($t = $start_page_num; $t <= $end_page_num; $t++) {
  1135. if ($page == $t) {
  1136. // current page
  1137. $rtn .= "<span class='pager-link pager-number pager-current'>$t</span>";
  1138. }
  1139. else {
  1140. $rtn .= "<span class='pager-link pager-number'>" . l($t, "admin/config/watchdog", $base_query . "&page=$t") . "</span>";
  1141. }
  1142. }
  1143. if ($end_page_num < $pages) {
  1144. $rtn .= "<span class='pager-elip'>...</span>";
  1145. }
  1146. if ($page < $pages) {
  1147. $rtn .= "<span class='pager-link pager-next'>" . l("next &gt;", "admin/config/watchdog", $base_query . "&page=" . ($page + 1)) . "</span>";
  1148. $rtn .= "<span class='pager-link pager-last'>" . l("last &raquo;", "admin/config/watchdog", $base_query . "&page=$pages") . "</span>";
  1149. }
  1150. else {
  1151. $rtn .= "<span class='pager-link pager-next'>next &gt;</span>";
  1152. $rtn .= "<span class='pager-link pager-last'>last &raquo;</span>";
  1153. }
  1154. $rtn .= "</div>";
  1155. return $rtn;
  1156. }
  1157. /**
  1158. * This is the "main" page for the admin module. It's what the user
  1159. * first sees when the click to go to the Admin page.
  1160. */
  1161. function admin_display_main() {
  1162. $de_catalog_year = admin_get_de_catalog_year(FALSE);
  1163. // Has the system cron been run recently?
  1164. $cron_last_run = variable_get("cron_last_run", 0);
  1165. if ($cron_last_run < strtotime("-7 DAY")) {
  1166. // Warn admin that they need to have cron set up! It's been over a week!
  1167. fpm(t("Your system's cron process hasn't run in over a week. In order for FlightPath
  1168. to continue to function properly, a cron process much be configured.
  1169. You may @run_link or see the @status_link page for instructions.",
  1170. array("@status_link" => l(t("System status"), "admin/config/status"),
  1171. "@run_link" => l(t("run cron now"), "admin/config/run-cron"))));
  1172. }
  1173. $rtn = "";
  1174. fp_add_css(fp_get_module_path("admin") . "/css/admin.css");
  1175. fp_add_js(fp_get_module_path("admin") . "/js/admin.js");
  1176. $rtn .= "<h2>" . t("FlightPath Admin Console - Main Menu") . "</h2>";
  1177. $rtn .= "<table class='fp-semester-table' cellpadding='5'>
  1178. <tr>
  1179. <td valign='top' width='50%'>
  1180. " . fp_render_menu_block(t("System Configuration"), "admin/config") . "
  1181. </td>
  1182. <td valign='top' width='50%'>
  1183. ";
  1184. // Advising Settings
  1185. $rtn .= fp_render_curved_line("Advising Settings");
  1186. $rtn .= "<div class='admin-advising-settings'>
  1187. <ul>
  1188. <li>" . t("Available terms for advising: %v", array("%v" => variable_get("available_advising_term_ids", ""))) . "</li>
  1189. <li>" . t("Default advising term: %v", array("%v" => variable_get("advising_term_id", ""))) . "</li>
  1190. <li>" . t("Current catalog year: %v", array("%v" => variable_get("current_catalog_year", ""))) . "</li>
  1191. <li>" . t("Current draft catalog year: %v", array("%v" => variable_get("current_draft_catalog_year", ""))) . "</li>
  1192. <li>" . t("Not released grades terms: %v", array("%v" => variable_get("not_released_grades_terms", ""))) . "</li>
  1193. </ul>";
  1194. if (user_has_permission("can_edit_advising_settings")) {
  1195. $rtn .= l(t("Edit Advising Settings"), "admin/edit-advising-settings");
  1196. }
  1197. $rtn .= "</div>";
  1198. $rtn .= "</td>
  1199. </tr>";
  1200. $rtn .= "</table><br>"; // close table
  1201. $settings = fp_get_system_settings();
  1202. if (user_has_permission("can_access_data_entry")) {
  1203. $rtn .= fp_render_curved_line("Data Entry");
  1204. $rtn .= "<div class='data-entry-cats'>";
  1205. // Have a pulldown here of years, then use javascript to hide/show relavant groups.
  1206. $rtn .= "&nbsp; &nbsp; &nbsp; " . t("Select a catalog year") . ": <select id='data-entry-select-cats' onChange='adminHideDECats();'>";
  1207. $selected_cat = ($de_catalog_year != "") ? $de_catalog_year : $settings["current_catalog_year"];
  1208. for ($t = $settings["current_catalog_year"] +1; $t >= $settings["earliest_catalog_year"]; $t--) {
  1209. $sel = ($t == $selected_cat) ? "selected" : "";
  1210. $rtn .= "<option value='$t' $sel>$t-" . ($t+1) . "</option>";
  1211. }
  1212. $rtn .= "</select>";
  1213. for ($t = $settings["current_catalog_year"] +1; $t >= $settings["earliest_catalog_year"]; $t--) {
  1214. $rtn .= "<ul class='data-entry-for-cat data-entry-for-cat-$t'>";
  1215. $rtn .= "<li>" . l(t("Degree plans for @year", array("@year" => "$t-" . ($t+1))), "admin/degrees", "de_catalog_year=$t") . "</li>";
  1216. $rtn .= "<li>" . l(t("Groups for @year", array("@year" => "$t-" . ($t+1))), "admin/groups", "de_catalog_year=$t") . "</li>";
  1217. $rtn .= "<li>" . l(t("Courses for @year", array("@year" => "$t-" . ($t+1))), "admin/courses", "de_catalog_year=$t") . "</li>";
  1218. $rtn .= "</ul>";
  1219. }
  1220. if (user_has_permission("can_edit_data_entry")) {
  1221. $rtn .= "<b>" . t("Administrator function:") . "</b><ul>
  1222. <li>" . l(t("Duplicate entire year worth of data to new year"), "admin/duplicate-year") . "</li>
  1223. </ul>";
  1224. }
  1225. $rtn .= "</div>";
  1226. // Draft changes?
  1227. $res = db_query("SELECT * FROM draft_instructions");
  1228. if (db_num_rows($res) > 0) {
  1229. $rtn .= "<div class='draft-changes-waiting-msg'>
  1230. " . t("Draft changes have been made which have yet to be applied.
  1231. When you are ready for your draft changes to appear in
  1232. production, click the link below.") . "</div>";
  1233. }
  1234. $rtn .= "<ul class='data-entry-draft-waiting'>
  1235. <li>" . l(t("Apply draft changes"), "admin/apply-draft-changes") . "</li>
  1236. </ul>";
  1237. }
  1238. return $rtn;
  1239. }

Functions

Namesort descending Description
admin_advising_settings_form This is a systems settings form, which lets the user edit advising variabled for FlightPath.
admin_apply_draft_changes_form This form lets the user apply draft changes (if they can supply the passcode)
admin_apply_draft_changes_form_submit Handles the actual moving of draft courses into production.
admin_display_main This is the "main" page for the admin module. It's what the user first sees when the click to go to the Admin page.
admin_display_watchdog Displays recent watchdog entries, from the watchdog table
admin_display_watchdog_entry Display the details of a particular watchdog entry, specified by its table id.
admin_duplicate_year_form This form will allow the user to duplicate an entire year's worth of data to a new catalog year.
admin_duplicate_year_form_submit This function should perform the actual copy of data!
admin_get_de_catalog_year Get the "de_catalog_year" from the REQUEST. If it's not there or invalid, pull it from our system settings.
admin_get_semester_name Convienence function to get semester's default regular name.
admin_menu Implementation of hook_menu
admin_menu_handle_replacement_pattern This is an implementation of hook_menu_handle_replacement_pattern. It will search for and replace replacement patterns which we are aware of it in $str.
admin_perm
admin_urgent_message_form Meant to be fed into "fp_system_settings_form()", this function returns an array which will automatically save values to our "variables" table.