hook.api.php

  1. 6.x includes/hook.api.php
  2. 4.x includes/hook.api.php
  3. 5.x includes/hook.api.php

Lists all available hooks within FlightPath's core code.

This script is not meant to be included and used in FlightPath, it is simply for documentation of how the various hooks work.

In each example, you may use a hook by replacing the word "hook" with the name of your custom module.

For example, hook_menu() might be my_module_menu(). FlightPath will automatically begin using the hooks in your module, once the module is enabled.

File

includes/hook.api.php
View source
  1. <?php
  2. /**
  3. * @file
  4. * Lists all available hooks within FlightPath's core code.
  5. *
  6. * This script is not meant to be included and used in FlightPath,
  7. * it is simply for documentation of how the various hooks work.
  8. *
  9. * In each example, you may use a hook by replacing the word "hook"
  10. * with the name of your custom module.
  11. *
  12. * For example, hook_menu() might be my_module_menu(). FlightPath
  13. * will automatically begin using the hooks in your module, once the
  14. * module is enabled.
  15. */
  16. /**
  17. * Alter forms which are created using the Form API
  18. *
  19. * @param &$form
  20. * This is the actual form array, retrieved from the form's callback
  21. * function. It should ALWAYS be passed by reference, so that the
  22. * changes you make to it will carry through.
  23. * @param $form_id
  24. * This is the "form_id" of the form-- usually the name of the callback
  25. * function which created the form. It can be used to identify forms
  26. * before you attempt to take action.
  27. *
  28. */
  29. function hook_form_alter(&$form, $form_id) {
  30. if ($form_id == "example_form_callback") {
  31. $form["new_element"] = array(
  32. // ...
  33. );
  34. }
  35. }
  36. /**
  37. * Used by the stats module, this will ask other modules to return an array
  38. * of paths suitable for the fp_render_menu_block() function. In other words,
  39. * the paths should be the **beginning** of the paths of your custom reports or other links
  40. * which you wish to show up on the stats screen.
  41. *
  42. * To see this in action, examine the stats.module file, function stats_display_main()
  43. * @see stats_display_main
  44. */
  45. function fpl_reports_stats_additional_menublocks() {
  46. return array(
  47. 'Custom Reports' => 'stats/custom-reports',
  48. 'Fancy Reports' => 'stats/fancy-reports',
  49. );
  50. }
  51. /**
  52. * This will let us re-arrange or add new elements to the Currently Advising box,
  53. * which appears at the top of the screen once a student has been selected (or for
  54. * a student when they log in).
  55. *
  56. * Values are stored as Strings for each element, in the format:
  57. * label ~~ value
  58. * For example:
  59. * [0] Name: ~~ John Doe
  60. * [1] Degree: ~~ Accounting
  61. *
  62. * NOTE: Because of when this hook is invoked, the fpm() function will not work
  63. * correctly to debug variables. Use ppm($var) instead.
  64. */
  65. function hook_alter_currently_advising_box(&$display_array) {
  66. // Add to the end...
  67. $display_array[] = 'Extra: ~~ Values';
  68. }
  69. /**
  70. * Similar to hook_form_alter, this function lets other modules alter
  71. * content which is being rendered through the "render" system.
  72. *
  73. * You may make changes to the render array.
  74. */
  75. function hook_content_alter(&$render, $render_id) {
  76. if ($render_id == 'some_id') {
  77. $render_array['extra'] = array(
  78. 'value' => 'Add this extra content.',
  79. );
  80. }
  81. }
  82. /**
  83. * This hook his called just before returning a Course object from CourseList::find_best_grade_match or find_most_recent_match.
  84. *
  85. * Returns TRUE or FALSE if the $candidate_course is allowed to match for the $needle_course.
  86. *
  87. * @param $degree_id This is the degree the course is trying to be matched within, if applicable.
  88. * @param $group_id This is the group the course is trying to be matched within, if applicable.
  89. *
  90. *
  91. * Note: it should ALWAYS return TRUE as the default case.
  92. *
  93. */
  94. function hook_courselist_find_match_allow_course(Course $candidate_course, Course $needle_course, CourseList $haystack_list_matches, $degree_id = 0, $group_id = 0) {
  95. if ($degree_id == 12345 && $candidate_course->name_equals('ART 101') && $group_id != 0) {
  96. return FALSE;
  97. }
  98. return TRUE;
  99. }
  100. /**
  101. * This hook is called right before retrieving the plain English description
  102. * for a term_id. It allows modules to change the term_id.
  103. *
  104. * Notice that term_id and $bool_abbreviate are passed by reference!
  105. */
  106. function hook_alter_term_id_prior_to_description(&$term_id, &$bool_abbreviate) {
  107. if ($term_id == "201740") {
  108. // change term_id to something else.
  109. $term_id = "555570";
  110. }
  111. }
  112. /**
  113. * Is the course allowed to be assigned to the specified degree? Returns TRUE or FALSE
  114. *
  115. * @return boolean
  116. */
  117. function hook_flightpath_can_assign_course_to_degree_id($degree_id, $course) {
  118. // See previously assigned degrees: $course->assigned_to_degree_ids_array
  119. return TRUE;
  120. } // ...can_assign_course_to_degree_id
  121. /**
  122. * Is the course allowed to be assigned to the specified group? Returns TRUE or FALSE.
  123. * $group should be a fully formed Group object.
  124. *
  125. * This is useful if you have a rule like "No course worth 3 hours is allowed in XYZ group" or something similar.
  126. *
  127. * @return boolean
  128. */
  129. function hook_flightpath_can_assign_course_to_group($group, $course) {
  130. //... Special logic here to see if this course is allowed in this group.
  131. return TRUE;
  132. }
  133. /**
  134. * This hook allows other modules to interact with the AdvisingScreen object
  135. * adter the build_screen_elements method is called.
  136. *
  137. * Of particular interest could be $advising_screen->box_array[]. This is an array of HTML
  138. * for the semester blocks which appear on the screen.
  139. */
  140. function hook_advise_build_screen_elements(&$advising_screen) {
  141. }
  142. /**
  143. * This hook allows another module to alter the way a "degree header" row is drawn onto the advising screen.
  144. *
  145. * These are the rows which appear above a new degree, and say "Required by degree_title", etc. This hook
  146. * allows modules to alter its content.
  147. *
  148. * To see how it is used,
  149. * @see _AdvisingScreen::display_semester()
  150. * @see _AdvisingScreenTypeView::display_semester_list()
  151. *
  152. *
  153. */
  154. function hook_theme_advise_degree_header_row(&$theme) {
  155. }
  156. /**
  157. * This hook allows another module to alter the way a course row is drawn onto the advising screen.
  158. */
  159. function hook_theme_advise_course_row(&$theme) {
  160. }
  161. /**
  162. * Similar to hook_theme_advise_course_row.
  163. * This lets the user theme the "select X hours..." row for a group.
  164. */
  165. function hook_theme_advise_group_select_row(&$theme) {
  166. }
  167. /**
  168. * Similar to other theme functions, this function will take an array which describes *all* the pie charts,
  169. * and allow another module to act on them.
  170. *
  171. * To see how it is used,
  172. * @see _AdvisingScreen::draw_progress_boxes()
  173. */
  174. function hook_theme_pie_charts(&$theme) {
  175. }
  176. /**
  177. * Reports status information which each module is aware of, visible on admin/config/status.
  178. *
  179. * This allows modules to let the user know about requirements which are not being met, or
  180. * simply to let them know that someting is working successfully.
  181. *
  182. * For example, you may want to let the user know that a nightly job failed to run the night before.
  183. *
  184. * @return array()
  185. * - severity: "normal", "warning", and "alert" are the choices.
  186. * - status: A short message.
  187. *
  188. */
  189. function hook_status() {
  190. // Example from system.module, reporting on if Cron has run recently:
  191. $rtn = array();
  192. $rtn["severity"] = "normal";
  193. // Check on the last time cron was run; make sure it's working properly.
  194. $last_run = variable_get("cron_last_run", 0);
  195. if ($last_run < strtotime("-2 DAY")) {
  196. $rtn["severity"] = "alert";
  197. $rtn["status"] .= t("Cron hasn't run in over 2 days. For your installation of FlightPath
  198. to function properly, cron.php must be accessed routinely. At least once per day is recommended.");
  199. }
  200. else {
  201. $rtn["status"] .= t("Cron was last run on %date", array("%date" => format_date($last_run)));
  202. }
  203. $rtn["status"] .= "<p style='font-size: 0.8em;'>" . t("Your site's cron URL is:");
  204. $rtn["status"] .= "<br>&nbsp; &nbsp; <i>" . $GLOBALS["fp_system_settings"]["base_url"] . "/cron.php?t=" . $GLOBALS["fp_system_settings"]["cron_security_token"] . "</i>
  205. <br>" . t("Example linux cron command:") . "&nbsp; <i>wget -O - -q -t 1 http://ABOVE_URL</i>";
  206. $rtn["status"] .= "</p>";
  207. return $rtn;
  208. }
  209. /**
  210. * Returns a full listing of the student's majors.
  211. *
  212. * @see fp_get_student_majors()
  213. */
  214. function hook_fp_get_student_majors($student_cwid, $bool_return_as_full_record = FALSE, $perform_join_with_degrees = TRUE, $bool_skip_directives = TRUE, $bool_check_for_allow_dynamic = TRUE) {
  215. // Example code from system.module:
  216. $db = get_global_database_handler();
  217. $rtn = $db->get_student_majors_from_db($student_cwid, $bool_return_as_full_record, $perform_join_with_degrees, $bool_skip_directives, $bool_check_for_allow_dynamic);
  218. return $rtn;
  219. }
  220. /**
  221. * Validates form submissions from the Form API
  222. *
  223. * This function can be named anything you want (or can be considered optional).
  224. * If named the same thing as the form callback, it will be utilized automatically.
  225. * For example, if you form is named my_form, then if you have a validate function
  226. * named my_form_validate, it will be called automatically.
  227. *
  228. * Since $form_state is passed by reference, you may make changes to this array, and
  229. * those changes will carry through to other validate functions (defined with #validate_handlers)
  230. * and then to the submit handler(s).
  231. *
  232. * @see hook_submit($form, &$form_state)
  233. */
  234. function hook_validate($form, &$form_state) {
  235. $age = $form_state["values"]["age"];
  236. if ($age < 18) {
  237. form_error("age", "Sorry, you must be 18 or older to submit this form.");
  238. return;
  239. }
  240. }
  241. /**
  242. * This hook is called every time the system cron is run.
  243. *
  244. * Modules should place code here which is meant to be run on a schedule.
  245. */
  246. function hook_cron() {
  247. // Example: check for students who have dropped, and email their advisors.
  248. }
  249. /**
  250. * Handle submissions from the Form API
  251. *
  252. * Like hook_validate, this function (if it exists) is called after you submit a form,
  253. * and after the validation completes without errors. This is where you should act on
  254. * the submission, confident that it has passed validation, and the values in $form_state
  255. * are in the final state.
  256. *
  257. * @see hook_validate($form, &$form_state)
  258. */
  259. function hook_submit($form, &$form_state) {
  260. $values = $form_state["values"];
  261. db_query("INSERT INTO example (f_name) ('?') ", $values["name"]);
  262. }
  263. /**
  264. * This hook will be executed the first time a module is enabled in the system.
  265. *
  266. * It is expected to go in a PHP file named [module].install. Ex: system.install
  267. *
  268. * @see hook_enable()
  269. * @see hook_disable()
  270. * @see hook_update($old_schema, $new_schema)
  271. * @see hook_uninstall()
  272. */
  273. function hook_install() {
  274. // Perform installation functions.
  275. db_query("CREATE TABLE ...... ");
  276. }
  277. /**
  278. * This hook will be executed when a module is enabled in the system. It will be
  279. * executed AFTER hook_install.
  280. *
  281. * It is expected to go in a PHP file named [module].install. Ex: system.install
  282. *
  283. * @see hook_install()
  284. * @see hook_disable()
  285. * @see hook_update($old_schema, $new_schema)
  286. * @see hook_uninstall()
  287. */
  288. function hook_enable() {
  289. fp_add_message("Don't forget to go to settings...");
  290. }
  291. /**
  292. * This hook will be executed when a module is disabled in the system.
  293. *
  294. * It is expected to go in a PHP file named [module].install. Ex: system.install
  295. *
  296. * @see hook_install()
  297. * @see hook_enable()
  298. * @see hook_update($old_schema, $new_schema)
  299. * @see hook_uninstall()
  300. */
  301. function hook_disable() {
  302. fp_add_message("Sorry to see you go!");
  303. }
  304. /**
  305. * This hook will be executed when a module is "uninstalled" in the system. Once
  306. * a module is disabled, an "uninstall" link will appear.
  307. *
  308. * It is expected to go in a PHP file named [module].install. Ex: system.install
  309. *
  310. * @see hook_install()
  311. * @see hook_enable()
  312. * @see hook_update($old_schema, $new_schema)
  313. * @see hook_disable()
  314. */
  315. function hook_uninstall() {
  316. db_query("DROP TABLE mycustomtable ... ");
  317. }
  318. /**
  319. * This hook will be executed when a module is "updated" in the system. If the system
  320. * sees that the schema version defined in the .info file is different than the one
  321. * in the database for that module, an update link will appear.
  322. *
  323. * It is expected to go in a PHP file named [module].install. Ex: system.install
  324. *
  325. * @see hook_install()
  326. * @see hook_enable()
  327. * @see hook_uninstall()
  328. * @see hook_disable()
  329. */
  330. function hook_update($old_schema, $new_schema) {
  331. if ($old_schema < 5) {
  332. db_query("ALTER TABLE ...... ");
  333. }
  334. }
  335. /**
  336. * Handle needed database updates when user updates a module.
  337. *
  338. * Modules can specify which schema their tables are using in their .info file.
  339. * if the module, in a later version, changes the table it writes to, it should increment
  340. * the schema number, whic causes the user to be notified (on the modules page) that they need
  341. * to run the DB updates.
  342. *
  343. * When the DB updates are run, every module implementing this function will be called
  344. * (it is expected to be in a .install file, instead of the .module file, though both get
  345. * included by the system first).
  346. *
  347. * In this function, the developer can see what schema they are coming FROM, and make table
  348. * or other alterations based on that information.
  349. *
  350. * @param $old_schema
  351. * This will be the schema value we are upgrading FROM. Ex: 0, 1, 17, etc.
  352. * @param $new_schema
  353. * This is the new schema value in the module's .info file, that
  354. * we are upgrading to. Ex: 2, 18, etc.
  355. *
  356. */
  357. function hook_update($old_schema, $new_schema) {
  358. if ($new_schema < 4) {
  359. db_query("ALTER TABLE my_example_table ...... ");
  360. }
  361. }
  362. /**
  363. * Allows each module to perform actions when the cache is cleared.
  364. *
  365. * If your custom module needs to clear its own cache, for example,
  366. * then you should implement this hook and place your module-specific
  367. * code inside.
  368. *
  369. */
  370. function hook_clear_cache() {
  371. db_query("DELETE FROM mymodule_cache_tables WHERE 1");
  372. }
  373. /**
  374. * Allows each module to execute code when the module is first loaded.
  375. *
  376. * Typically, this means that we will execute code when the page is first loaded.
  377. * Also useful for including javascript or CSS on the page, but only under certain
  378. * conditions (like who the user is, or what permissions they have)
  379. *
  380. * @see hook_exit
  381. */
  382. function hook_init() {
  383. // Perform actions when page is loaded...
  384. if (user_has_access("some_permission")) {
  385. $GLOBALS["some_variable"] = TRUE;
  386. }
  387. }
  388. /**
  389. * Allows each module to execute code when the FlightPath page is completely finished.
  390. *
  391. * Be aware that theming and themable functions will not work, since this hook is called
  392. * after the page has been completely rendered. If you need to output debug statements for yourself,
  393. * use echo or print, and it will be at the BOTTOM of the page.
  394. *
  395. * @see hook_init
  396. */
  397. function hook_exit() {
  398. // ex: Close outside db connections
  399. // ex: print "Time for page to load:" . $ctime;
  400. }
  401. /**
  402. * Perform actions when the user logs in successfully.
  403. *
  404. * Notice that $account is passed by reference. You may make whatever changes
  405. * you wish to this object.
  406. */
  407. function hook_user_login(&$account) {
  408. if ($account->uid = 9) {
  409. $account->this_is_jeff = TRUE;
  410. }
  411. }
  412. /**
  413. * This hook defines available permissions for a module.
  414. * These perms are used with hook_menu() and the function user_has_permission()
  415. *
  416. * They are defined in the form of an associative array.
  417. *
  418. * Return array should look like this:
  419. * $rtn["machine_name_of_perm"] = array(
  420. * "title" => "Human readable title for perm",
  421. * "description" => "Optional longer description of what perm allows.",
  422. * );
  423. *
  424. * @return array
  425. *
  426. * @see hook_menu()
  427. * @see user_has_permission()
  428. *
  429. */
  430. function hook_perm() {
  431. // An example from system.module:
  432. $perms = array (
  433. "access_logged_in_content" => array(
  434. "title" => t("Access logged-in content"),
  435. "description" => t("This should be given to all authenticated users. It simply means
  436. the user is allowed to view the logged-in area of FlightPath."),
  437. ),
  438. "administer_modules" => array(
  439. "title" => t("Administer modules"),
  440. "description" => t("This will allow a user to install, enable, disable, and uninstall modules."),
  441. ),
  442. "run_cron" => array(
  443. "title" => t("Run Cron"),
  444. "description" => t("The user may run hook_cron functions at will. Causes a new menu link to appear
  445. on the admin page."),
  446. ),
  447. "de_can_administer_system_settings" => array(
  448. "title" => t("Can administer system settings"),
  449. "description" => t("This allows the user to edit any of the FlightPath
  450. system settings."),
  451. ),
  452. "view_fpm_debug" => array(
  453. "title" => t("View debug output from the fpm() function"),
  454. "description" => t("The user may view debug output from the fpm() function.
  455. Useful for developers."),
  456. ),
  457. );
  458. return $perms;
  459. }
  460. /**
  461. * Allows modules to hook in after a new student object is created.
  462. *
  463. * This is so that modules can modify student objects (including what courses they
  464. * have taken) when that student object is first created. For example, if you need
  465. * to query extra databases to get all of a student's credits.
  466. */
  467. function hook_student_load(&$student) {
  468. if ($student->gpa > 3) {
  469. $student->deans_list = TRUE;
  470. }
  471. }
  472. /**
  473. * Allows modules to hook in after a degree plan object is created & loaded.
  474. *
  475. * Specifically, this is called at the end of the DegreePlan::load_degree_plan() method is called.
  476. *
  477. * Similar concept to hook_student_load
  478. *
  479. * @see hook_student_load()
  480. */
  481. function hook_degree_plan_load(&$degree) {
  482. if ($degree->major_code == 'XYZ') {
  483. $degree->is_xyz = TRUE;
  484. }
  485. }
  486. /**
  487. * Allows modules to act after a group object has been loaded.
  488. *
  489. * Specifically, this is called at the end of Group::load_group()
  490. *
  491. * @see hook_degree_plan_load()
  492. */
  493. function hook_group_load(&$group) {
  494. if ($group->group_name == "YXZ") {
  495. $group->is_xyz = TRUE;
  496. }
  497. }
  498. /**
  499. * Allows modules to act after a course object has been loaded.
  500. *
  501. * Specifically, this is called at the end of Course::load_course()
  502. *
  503. * @see hook_degree_plan_load()
  504. */
  505. function hook_course_load(&$course) {
  506. if ($course->subject_id == "YXZ") {
  507. $course->is_xyz = TRUE;
  508. }
  509. }
  510. /**
  511. * Allows modules to execute code when the admin user has chose to "apply draft changes".
  512. */
  513. function hook_apply_draft_changes() {
  514. $table_name = "my_module_table";
  515. $draft_table_name = "draft_$table_name";
  516. // First, truncate existing...
  517. $query = "truncate table $table_name";
  518. $res = db_query($query);
  519. // Now, copy in draft changes...
  520. $query = "INSERT INTO $table_name
  521. SELECT * FROM $draft_table_name ";
  522. $res = db_query($query);
  523. }
  524. /**
  525. * Allows modules to specify valid URLs in FlightPath, and define what function to call
  526. * when the user visits that URL.
  527. *
  528. * After making changes to your hook menu, you <b>must</b> clear the menu cache for FlightPath!
  529. * Otherwise, FlightPath will not be aware of your changes. This can be done on the /admin-tools/admin page.
  530. *
  531. * This function should return an array containing everything FP needs to correctly set up
  532. * the menu item.
  533. *
  534. * First, the index of the array should be the URL itself.
  535. * Ex: $items["my/url"] = array(
  536. * ...
  537. * );
  538. *
  539. * The URL is allowed to contain wildcards (%).
  540. * Ex:
  541. * $items["content/%/edit"] = array(...);
  542. *
  543. * The wildcard is in position "1", since the URL pieces begin with zero ("0").
  544. *
  545. * Here are what the inner parts of the array mean:
  546. * - title : The title of the page or menu item. Should not be wrapped in t() function.
  547. * - page_callback: A string which defines the function to call when this URL is accessed.
  548. * - page_arguments: An optional array of arguments to pass to the callback function. May contain numerican references to wildcards in the URL.
  549. * - access_callback: A string which defines a function to call to determine if the user may access this URL.
  550. * Can be set to TRUE if this URL is open to anyone. May be omitted if you simply want to test if the user has a particular
  551. * permission, by only setting access_arguments.
  552. * - access_arguments: An array containing the arguments to pass to the access_callback function. If the access_callback
  553. * function is omitted, it is assumed to be "user_has_permission", in which case you may simply specify
  554. * an array of permissions here. May contain numerican references to wildcards in the URL.
  555. * - type: A constant value describing the type of menu item it is. Examples are:
  556. * - MENU_TYPE_NORMAL_ITEM - A standard menu item. Will output as a link if the URL conforms to certain requirements.
  557. * - MENU_TYPE_CALLBACK - A menu item which will not display itself on any blocks.
  558. * - MENU_TYPE_TAB - A menu item which will output the page it draws with a tab at the top, or part of a tab family.
  559. * - MENU_TYPE_SUB_TAB - This will output the page as a "sub tab" under the main tab. Ex: the student search tab's subtabs, or
  560. * the View tab's Display by Year and Display By Type sub tabs.
  561. * - tab_family: If this menu item is a tab, specifying a machine name for the tab family will group all other tabs
  562. * in that family together, and draw the other tabs in that family at the top of the screen.
  563. * - tab_parent: The *path* of the parent tab for this menu item. Will cause the parent tab's name to be displayed
  564. * as a tab at the top of the page. Ex: "admin-tools/admin"
  565. * - weight: Optional number, for when menu items are being displayed in a block. Smaller weights appear first.
  566. * - file: Path to a file that this menu item's callback is located in.
  567. * - page_settings: This is an optional array which allows for more detailed control over how the menu item and the page
  568. * it draws will look. Ex: "page_settings" => array( //....//); See below:
  569. * - page_has_search: TRUE or FALSE, whether or not the search box will be drawn at the top of the screen. This is the
  570. * search box which searches for students.
  571. * - page_show_title: TRUE if the page should display the title at the top of the content region.
  572. * - page_banner_is_link: TRUE or FALSE. Does the banner at the top of the screen link back to the Main tab. Not implemented right now.
  573. * - page_hide_report_error: TRUE or FALSE. Should the "Contact the FlightPath Production Team" link be shown at the bottom of the screen.
  574. * - page_is_popup: TRUE or FALSE. Whether or not the page is going to be displayed in a popup. Will remove the banner and other
  575. * elements which might not look good in a popup window.
  576. * - display_greeting: TRUE or FALSE. Should the page have the greeting text at the top? Ex: see the Main tab.
  577. * - display_currently_advising: TRUE or FALSE. Should the page display the "Currently Advising" box at the top of the page?
  578. * - screen_mode: If set to "not_advising" while display_currently_advising is set to TRUE, it will not display the options
  579. * to change degree options or advising terms.
  580. * - bool_print: Set to TRUE if this page is meant to be printable (it is formatted to print easily).
  581. * - target: The anchor target of this menu item (if it is drawn in a block). Ex: "_blank"
  582. * - menu_icon: A string which points to an icon to display with this link, if it is being displayed in a block.
  583. * - menu_links: An array of links. This is an array of parameters which would fit very will into the l() function.
  584. * The links will appear as simple links at the top of the page. Will be filtered through hook_menu_handle_replacement_pattern().
  585. * Ex: "menu_links" => array(0 => array("text"=>"link", "path"=>"admin/tools", "query"=>"name=bob"))
  586. * - 0..n
  587. * - text: The text of the link
  588. * - path: The internal path of the link. Ex: "admin-tools/admin"
  589. * - query: Optional query to add to the end of the URL. Ex: "de_catalog_year=%DE_CATALOG_YEAR%"
  590. * Will be filtered through hook_menu_handle_replacement_pattern()
  591. *
  592. *
  593. * See the examples below for demonstrations of typical menu items.
  594. *
  595. * @return array
  596. *
  597. * @see hook_perm()
  598. * @see hook_menu_handle_replacement_pattern()
  599. *
  600. */
  601. function hook_menu() {
  602. // Examples from various modules:
  603. $items = array();
  604. $items["main"] = array(
  605. "title" => "Main",
  606. "page_callback" => "system_display_main_page",
  607. "access_callback" => TRUE,
  608. "type" => MENU_TYPE_TAB,
  609. "tab_family" => "system",
  610. "weight" => 10,
  611. "page_settings" => array(
  612. "display_greeting" => TRUE,
  613. "display_currently_advising" => TRUE,
  614. "screen_mode" => "not_advising",
  615. "page_has_search" => TRUE,
  616. ),
  617. );
  618. $items["login"] = array(
  619. "title" => "Login",
  620. "page_callback" => "system_display_login_page",
  621. "access_callback" => TRUE,
  622. "type" => MENU_TYPE_NORMAL_ITEM,
  623. );
  624. $items["admin-tools/clear-cache"] = array(
  625. "title" => "Clear all cache",
  626. "page_callback" => "system_perform_clear_cache",
  627. "access_arguments" => array("administer_modules"),
  628. "type" => MENU_TYPE_NORMAL_ITEM,
  629. );
  630. $items["admin/db-updates"] = array(
  631. "title" => "Run DB updates?",
  632. "page_callback" => "fp_render_form",
  633. "page_arguments" => array("system_confirm_db_updates_form"),
  634. "access_arguments" => array("administer_modules"),
  635. "type" => MENU_TYPE_NORMAL_ITEM,
  636. );
  637. $items["admin/config/system-settings"] = array(
  638. "title" => "System settings",
  639. "page_callback" => "fp_render_form",
  640. "page_arguments" => array("system_settings_form", "system_settings"),
  641. "access_arguments" => array("de_can_administer_system_settings"),
  642. "page_settings" => array(
  643. "page_has_search" => FALSE,
  644. "page_banner_is_link" => TRUE,
  645. "page_hide_report_error" => TRUE,
  646. "menu_icon" => fp_theme_location() . "/images/toolbox.gif",
  647. "menu_links" => array(
  648. 0 => array(
  649. "text" => "Back to main menu",
  650. "path" => "admin-tools/admin",
  651. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  652. ),
  653. ),
  654. ),
  655. "type" => MENU_TYPE_NORMAL_ITEM,
  656. "tab_parent" => "admin-tools/admin",
  657. );
  658. $items["admin-tools/admin"] = array(
  659. "title" => "FlightPath Admin Console",
  660. "page_callback" => "admin_display_main",
  661. "access_arguments" => array("can_access_admin"),
  662. "tab_family" => "admin",
  663. "page_settings" => array(
  664. "page_has_search" => FALSE,
  665. "page_banner_is_link" => TRUE,
  666. "page_hide_report_error" => TRUE,
  667. "target" => "_blank",
  668. ),
  669. "type" => MENU_TYPE_TAB,
  670. );
  671. $items["admin/config/modules"] = array(
  672. "title" => "Modules",
  673. "page_callback" => "fp_render_form",
  674. "page_arguments" => array("system_modules_form"),
  675. "access_arguments" => array("administer_modules"),
  676. "page_settings" => array(
  677. "page_has_search" => FALSE,
  678. "page_banner_is_link" => TRUE,
  679. "page_hide_report_error" => TRUE,
  680. "menu_links" => array(
  681. 0 => array(
  682. "text" => "Back to main menu",
  683. "path" => "admin-tools/admin",
  684. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  685. ),
  686. ),
  687. ),
  688. "type" => MENU_TYPE_NORMAL_ITEM,
  689. "tab_parent" => "admin-tools/admin",
  690. );
  691. $items["view/print"] = array(
  692. "title" => "View",
  693. "page_callback" => "advise_display_view",
  694. "page_arguments" => array("view"),
  695. "access_callback" => TRUE,
  696. "page_settings" => array (
  697. "display_currently_advising" => TRUE,
  698. "bool_print" => TRUE,
  699. "screen_mode" => "not_advising",
  700. ),
  701. "type" => MENU_TYPE_CALLBACK,
  702. );
  703. $items["admin/config/clear-menu-cache"] = array(
  704. "title" => "Clear menu cache",
  705. "page_callback" => "system_perform_clear_menu_cache",
  706. "access_arguments" => array("administer_modules"),
  707. "type" => MENU_TYPE_NORMAL_ITEM,
  708. );
  709. $items["system-handle-form-submit"] = array(
  710. "page_callback" => "system_handle_form_submit",
  711. "access_callback" => TRUE,
  712. "type" => MENU_TYPE_CALLBACK,
  713. );
  714. $items["logout"] = array(
  715. "title" => "Logout",
  716. "page_callback" => "system_handle_logout",
  717. "access_callback" => TRUE,
  718. "type" => MENU_TYPE_CALLBACK,
  719. );
  720. $items["popup-report-contact"] = array(
  721. "title" => "Report/Contact",
  722. "page_callback" => "fp_render_form",
  723. "page_arguments" => array("system_popup_report_contact_form"),
  724. "access_callback" => TRUE,
  725. "page_settings" => array(
  726. "page_is_popup" => TRUE,
  727. "page_hide_report_error" => TRUE,
  728. ),
  729. "type" => MENU_TYPE_CALLBACK,
  730. );
  731. $items["popup-contact-form/thank-you"] = array(
  732. "title" => "Report/Contact",
  733. "page_callback" => "system_popup_report_contact_thank_you",
  734. "access_callback" => TRUE,
  735. "page_settings" => array(
  736. "page_is_popup" => TRUE,
  737. "page_hide_report_error" => TRUE,
  738. ),
  739. "type" => MENU_TYPE_CALLBACK,
  740. );
  741. $items["admin/degrees/add-degree"] = array(
  742. "title" => "Add Degree",
  743. "page_callback" => "fp_render_form",
  744. "page_arguments" => array("admin_add_degree_form"),
  745. "access_arguments" => array("can_edit_data_entry"),
  746. "page_settings" => array(
  747. "page_has_search" => FALSE,
  748. "page_banner_is_link" => TRUE,
  749. "page_hide_report_error" => TRUE,
  750. "menu_links" => array(
  751. 0 => array(
  752. "text" => "Back to main menu",
  753. "path" => "admin-tools/admin",
  754. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  755. ),
  756. 1 => array(
  757. "text" => "Back to Degrees list",
  758. "path" => "admin/degrees",
  759. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  760. ),
  761. ),
  762. ),
  763. "file" => menu_get_module_path("admin") . "/admin.degrees.inc",
  764. "type" => MENU_TYPE_NORMAL_ITEM,
  765. "tab_parent" => "admin/degrees",
  766. );
  767. $items["admin/config/content"] = array(
  768. "title" => "Content",
  769. "page_callback" => "content_display_content_admin_list",
  770. "access_arguments" => array("admin_content"),
  771. "page_settings" => array(
  772. "page_has_search" => FALSE,
  773. "page_show_title" => TRUE,
  774. "page_banner_is_link" => TRUE,
  775. "page_hide_report_error" => TRUE,
  776. "menu_links" => array(
  777. 0 => array(
  778. "text" => "Back to main menu",
  779. "path" => "admin-tools/admin",
  780. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  781. ),
  782. ),
  783. ),
  784. "type" => MENU_TYPE_TAB,
  785. "tab_family" => "content_list",
  786. );
  787. $items["content/%"] = array(
  788. "page_callback" => "content_view_content",
  789. "page_arguments" => array(1),
  790. "access_callback" => "content_user_access",
  791. "access_arguments" => array("view_cid", 1),
  792. "page_settings" => array(
  793. "page_has_search" => FALSE,
  794. "page_show_title" => TRUE,
  795. "page_banner_is_link" => TRUE,
  796. "page_hide_report_error" => TRUE,
  797. "menu_links" => array(
  798. 0 => array(
  799. "text" => "Edit this content",
  800. "path" => "content/%CONTENT_CID%/edit",
  801. "query" => "",
  802. ),
  803. ),
  804. ),
  805. "type" => MENU_TYPE_TAB,
  806. "tab_parent" => "admin/config/content",
  807. );
  808. $items["content/%/edit"] = array(
  809. "page_callback" => "fp_render_form",
  810. "page_arguments" => array("content_edit_content_form", "", "", 1),
  811. "access_callback" => "content_user_access",
  812. "access_arguments" => array("edit_cid", 1),
  813. "page_settings" => array(
  814. "page_has_search" => FALSE,
  815. "page_banner_is_link" => TRUE,
  816. "page_hide_report_error" => TRUE,
  817. "menu_links" => array(
  818. 0 => array(
  819. "text" => "Back to main menu",
  820. "path" => "admin-tools/admin",
  821. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  822. ),
  823. 1 => array(
  824. "text" => "Back to content list",
  825. "path" => "admin/config/content",
  826. "query" => "de_catalog_year=%DE_CATALOG_YEAR%",
  827. ),
  828. ),
  829. ),
  830. "type" => MENU_TYPE_TAB,
  831. "tab_parent" => "admin/config/content",
  832. );
  833. return $items;
  834. }
  835. /**
  836. * This function allowes the user to theme footnotes before they are draw onto the screen.
  837. *
  838. */
  839. function hook_theme_advise_footnote(&$theme) {
  840. }
  841. /**
  842. * This function is called by the t() function, and gives modules a chance to intercept
  843. * a string and change it. Meant primarily for translating to another language, but also
  844. * good for simple replacements. Used by the Locale module.
  845. *
  846. * NOTE: Since str is passed by reference, we don't need to return it.
  847. */
  848. function hook_translate(&$str, $langcode = NULL) {
  849. // Ex:
  850. $str = str_replace("something", "something_else", $str);
  851. // Since str is passed by reference, we don't need to return it.
  852. }
  853. /**
  854. * This hook lets us make alterations to menu items before saving them to the database.
  855. *
  856. * It is only called when the menu cache is cleared and being rebuilt.
  857. *
  858. * Notice that $items is passed by reference, so you must make changes to the
  859. * $items array if you want those changes saved, as seen in the xample below.
  860. *
  861. */
  862. function hook_menu_alter(&$items) {
  863. foreach ($items as $path => $item) {
  864. if ($path == 'admin/config/some-path') {
  865. $items[$path]['access_callback'] = 'new_function_name';
  866. }
  867. }
  868. }
  869. /**
  870. * This hook is called by the menu system. It allows each module
  871. * the change to replace string patterns in its menu items (defined in hook_menu).
  872. *
  873. * @see hook_menu()
  874. */
  875. function hook_menu_handle_replacement_pattern($str) {
  876. /*
  877. * This example, from admin.module, will replace the pattern %DE_CATALOG_YEAR%
  878. * with the actual current catalog year in the system.
  879. *
  880. * An example menu item which uses this replacement pattern would be this:
  881. * $items["admin/config/urgent-message"] = array(
  882. * "title" => "Edit urgent message",
  883. * "page_callback" => "fp_render_form",
  884. * "page_arguments" => array("admin_urgent_message_form", "system_settings"),
  885. * "access_arguments" => array("can_edit_urgent_message"),
  886. * "page_settings" => array(
  887. * "page_has_search" => FALSE,
  888. * "page_banner_is_link" => TRUE,
  889. * "page_hide_report_error" => TRUE,
  890. * "menu_links" => array(
  891. * 0 => array(
  892. * "text" => "Back to main menu",
  893. * "path" => "admin-tools/admin",
  894. * "query" => "de_catalog_year=%DE_CATALOG_YEAR%", // RIGHT HERE!
  895. * ),
  896. * ),
  897. * ),
  898. * "type" => MENU_TYPE_NORMAL_ITEM,
  899. * "tab_parent" => "admin-tools/admin",
  900. * );
  901. *
  902. */
  903. if (strpos($str, "%DE_CATALOG_YEAR%") !== 0) {
  904. // It contains this replacement pattern!
  905. $str = str_replace("%DE_CATALOG_YEAR%", admin_get_de_catalog_year(), $str);
  906. }
  907. return $str;
  908. }
  909. /**
  910. * This hook allows modules to perform extra functions just after an advising
  911. * session is saved by the system.
  912. *
  913. * The main advising form (on the View and What If tabs) are currently _not_ defined
  914. * through the system's form API. Therefore, a simple hook_submit wouldn't be possible.
  915. *
  916. * This hook was created to bridge that gap, until the advising form can be brought into
  917. * the form API (possibly by 5.x)
  918. *
  919. * Advising session values should still be in _REQUEST or _POST.
  920. *
  921. *
  922. * @param $adv_id_array
  923. * Since this hook is called immediately after submitting the advising session,
  924. * this array will contain the database ID's to the rows added to the advising_sessions table.
  925. *
  926. */
  927. function hook_save_advising_session_from_post ($student_id, $is_draft, $adv_id_array) {
  928. foreach ($adv_id_array as $id) {
  929. // Perform extra actions on those advising sessions.
  930. }
  931. // Example functions:
  932. // Email student a copy of what was just advised for them to take.
  933. // Maybe lift an advising flag in the mainframe system?
  934. }

Functions

Namesort descending Description
fpl_reports_stats_additional_menublocks Used by the stats module, this will ask other modules to return an array of paths suitable for the fp_render_menu_block() function. In other words, the paths should be the **beginning** of the paths of your custom reports or other links which you…
hook_advise_build_screen_elements This hook allows other modules to interact with the AdvisingScreen object adter the build_screen_elements method is called.
hook_alter_currently_advising_box This will let us re-arrange or add new elements to the Currently Advising box, which appears at the top of the screen once a student has been selected (or for a student when they log in).
hook_alter_term_id_prior_to_description This hook is called right before retrieving the plain English description for a term_id. It allows modules to change the term_id.
hook_apply_draft_changes Allows modules to execute code when the admin user has chose to "apply draft changes".
hook_clear_cache Allows each module to perform actions when the cache is cleared.
hook_content_alter Similar to hook_form_alter, this function lets other modules alter content which is being rendered through the "render" system.
hook_courselist_find_match_allow_course This hook his called just before returning a Course object from CourseList::find_best_grade_match or find_most_recent_match.
hook_course_load Allows modules to act after a course object has been loaded.
hook_cron This hook is called every time the system cron is run.
hook_degree_plan_load Allows modules to hook in after a degree plan object is created & loaded.
hook_disable This hook will be executed when a module is disabled in the system.
hook_enable This hook will be executed when a module is enabled in the system. It will be executed AFTER hook_install.
hook_exit Allows each module to execute code when the FlightPath page is completely finished.
hook_flightpath_can_assign_course_to_degree_id Is the course allowed to be assigned to the specified degree? Returns TRUE or FALSE
hook_flightpath_can_assign_course_to_group Is the course allowed to be assigned to the specified group? Returns TRUE or FALSE. $group should be a fully formed Group object.
hook_form_alter Alter forms which are created using the Form API
hook_fp_get_student_majors Returns a full listing of the student's majors.
hook_group_load Allows modules to act after a group object has been loaded.
hook_init Allows each module to execute code when the module is first loaded.
hook_install This hook will be executed the first time a module is enabled in the system.
hook_menu Allows modules to specify valid URLs in FlightPath, and define what function to call when the user visits that URL.
hook_menu_alter This hook lets us make alterations to menu items before saving them to the database.
hook_menu_handle_replacement_pattern This hook is called by the menu system. It allows each module the change to replace string patterns in its menu items (defined in hook_menu).
hook_perm This hook defines available permissions for a module. These perms are used with hook_menu() and the function user_has_permission()
hook_save_advising_session This hook allows modules to perform extra functions just after an advising session is saved by the system.
hook_save_advising_session_from_post This hook allows modules to perform extra functions just after an advising session is saved by the system.
hook_status Reports status information which each module is aware of, visible on admin/config/status.
hook_student_load Allows modules to hook in after a new student object is created.
hook_submit Handle submissions from the Form API
hook_theme_advise_course_row This hook allows another module to alter the way a course row is drawn onto the advising screen.
hook_theme_advise_degree_header_row This hook allows another module to alter the way a "degree header" row is drawn onto the advising screen.
hook_theme_advise_footnote This function allowes the user to theme footnotes before they are draw onto the screen.
hook_theme_advise_group_select_row Similar to hook_theme_advise_course_row. This lets the user theme the "select X hours..." row for a group.
hook_theme_pie_charts Similar to other theme functions, this function will take an array which describes *all* the pie charts, and allow another module to act on them.
hook_translate This function is called by the t() function, and gives modules a chance to intercept a string and change it. Meant primarily for translating to another language, but also good for simple replacements. Used by the Locale module.
hook_uninstall This hook will be executed when a module is "uninstalled" in the system. Once a module is disabled, an "uninstall" link will appear.
hook_update Handle needed database updates when user updates a module.
hook_user_login Perform actions when the user logs in successfully.
hook_validate Validates form submissions from the Form API