privatemsg.api.php

  1. 1 privatemsg.api.php
  2. 7-1 privatemsg.api.php
  3. 7-2 privatemsg.api.php
  4. 6-2 privatemsg.api.php

Privatemsg API Documentation

File

privatemsg.api.php
View source
  1. <?php
  2. /**
  3. * @file
  4. * Privatemsg API Documentation
  5. */
  6. /**
  7. * @mainpage Privatemsg API Documentation
  8. * This is the API documentation of Privatemsg.
  9. *
  10. * - Topics:
  11. * - @link api API functions @endlink
  12. * - @link sql Query builder and related hooks @endlink
  13. * - @link message_hooks Message hooks @endlink
  14. * - @link generic_hooks Generic hooks @endlink
  15. * - @link theming Theming @endlink
  16. * - @link types Types of recipients @endlink
  17. */
  18. /**
  19. * @defgroup sql Query Builder
  20. * Privatemsg does use its own simple query builder which allows to extend
  21. * SELECT-Queries in an easy way. The function _privatemsg_assemble_query
  22. * creates the query, based on an array $fragments with the following content.
  23. * Except primary_table, each key is an array itself to allow multiple values
  24. *
  25. * - primary_table: The main table to select from
  26. * - select: The fields that should be selected. This can be a simple field, a
  27. * field with alias or even a subquery.
  28. * - inner_join: The tables that should be joined. This is not specific to
  29. * inner joins.
  30. * Example: INNER JOIN pm_index pmi ON (pmi.mid = pm.mid)
  31. * - where: The where conditions. The conditions are always AND, but it is
  32. * possible to use OR inside a condition.
  33. * Example: ⁽pmi.is_new = 1 OR pmi.deleted = 1)
  34. * - order_by: Order By values, example: pm.timestamp ASC
  35. * - query_args: It is possible to use the placeholders like %s in each part of
  36. * the query. The values of query_args are then inserted into these.
  37. * query_args consists of three arrays (join, where, having), one for each
  38. * key that currently supports arguments.
  39. *
  40. * Use _privatemsg_assemble_query
  41. *
  42. * The privatemsg_assemble_query function takes a query_id as first argument
  43. * and optionally one or multiple arguments. query_id can either be a
  44. * string ('some_id') or an array('group_name', 'query_id'), if a string
  45. * is supplied, group_name defaults to 'privatemsg'. Returned is an array
  46. * with the keys 'query' (normal query) and 'count' (count query for pager).
  47. *
  48. * For the actual query data, the function group_name_sql_query_id is executed,
  49. * this functions does have $fragments as first parameter and then the
  50. * optional parameters.
  51. *
  52. * A short example:
  53. * @code
  54. * // First, create the sql function.
  55. * function privatemsg_sql_getsubject(&$fragments, $mid, $uid) {
  56. * // Set the primary table.
  57. * $fragments['primary_table'] = '{pm_message} pm';
  58. *
  59. * // Add a field.
  60. * $fragments['select'][] = 'pm.subject';
  61. *
  62. * // Join another table.
  63. * $fragment['inner_join'][] = 'JOIN {pm_index} pi ON (pi.mid = pm.mid)';
  64. * $fragment['query_args']['join'][] $uid;
  65. *
  66. * // And finally add a condition.
  67. * $fragments['where'][] = 'pm.mid = %d';
  68. * $fragments['query_args']['where'][] = $mid;
  69. * }
  70. *
  71. * // Now we can use that query everywhere.
  72. * $query = _privatemsg_assemble_query('getsubject', 5);
  73. * $result = db_query($query['query']);
  74. * @endcode
  75. * Extend existing queries
  76. *
  77. * To extend a privatemsg query, use hook_group_name_sql_query_id_alter.
  78. * This hook does use the same parameters as the sql function.
  79. *
  80. * Example:
  81. * @code
  82. * function mymodule_privatemsg_sql_getsubject_alter(&$fragments, $mid) {
  83. * // we want to load the body too..
  84. * $fragments['select'][] = 'pm.body';
  85. * }
  86. * @endcode
  87. *
  88. * - List of sql query hooks.
  89. * - list: List of messages, Parameters: $fragments, $accounty
  90. * - list_sent: List of sent messages, Parameters: $fragments, $accounty
  91. * - load: Load a single message, Parameters: $fragments, $pmid, $account
  92. * - messages: Load the messages of a thread,
  93. * Parameters: $fragments, $thread_id, $account
  94. * - autocomplete: Searching usernames for the autocomplete feature,
  95. * Parameters: $fragments, $search, $names
  96. * - participants: Loads all participants of a thread,
  97. * Parameters: $fragments, $thread_id
  98. * - unread_count: Number of unread messages for a user,
  99. * Parameters: $fragments, $account
  100. *
  101. * - The following query_id's are used in pm_block_user
  102. * - threadautors: Return all authors of one or multiple threads,
  103. * Parameters: $fragments, $threads
  104. */
  105. /**
  106. * @addtogroup sql
  107. * @{
  108. */
  109. /**
  110. * Query to search for autocomplete usernames.
  111. *
  112. * @param $fragments
  113. * Query fragments
  114. * @param $search
  115. * Search for that username
  116. * @param $names
  117. * Names that are already in the list and are excluded
  118. */
  119. function hook_privatemsg_sql_autocomplete_alter(&$fragments, $search, $names) {
  120. global $user;
  121. // Extend the query that searches for usernames
  122. // $fragments is explained in the api documentation in detail
  123. // The query is already set up, it's searching for usernames which start with
  124. // $search and are not $names (may be empty)
  125. // the main table is {user} a
  126. // for example, add a join on a table where the user connections are stored
  127. // and specify that only users connected with the current user should be
  128. // loaded.
  129. $fragments['inner_join'] = 'INNER JOIN {my_table} m ON (m.user1 = u.uid AND m.user2 = %d)';
  130. $fragments['query_args'][] = $user->uid;
  131. }
  132. /**
  133. * Display a list of threads.
  134. *
  135. * @param $fragments
  136. * Query fragments
  137. * @param $account
  138. * User object
  139. */
  140. function hook_privatemsg_sql_list_alter(&$fragment, $account) {
  141. }
  142. /**
  143. * Query definition to load a message.
  144. *
  145. * @param $fragments
  146. * Query fragments array.
  147. * @param $pmid
  148. * the id of the message.
  149. * @param $account
  150. * User object of account for which to load the message.
  151. */
  152. function hook_privatemsg_sql_load_alter(&$fragments, $pmid, $account = NULL) {
  153. }
  154. /**
  155. * Query definition to load messages of one or multiple threads.
  156. *
  157. * @param $fragments
  158. * Query fragments array.
  159. * @param $threads
  160. * Array with one or multiple thread id's.
  161. * @param $account
  162. * User object for which the messages are being loaded.
  163. * @param $load_all
  164. * Deleted messages are only loaded if this is set to TRUE.
  165. */
  166. function hook_privatemsg_sql_messages_alter(&$fragments, $threads, $account = NULL, $load_all = FALSE) {
  167. }
  168. /**
  169. * Alter the query that loads the participants of a thread.
  170. *
  171. * @param $fragments
  172. * Query fragments
  173. * @param $thread_id
  174. * Thread id, pmi.thread_id is the same as the mid of the first
  175. * message of that thread
  176. */
  177. function hook_privatemsg_sql_participants_alter(&$fragment, $thread_id) {
  178. }
  179. /**
  180. * Loads all unread messages of a user (only the count query is used).
  181. *
  182. * @param $fragments
  183. * Query fragments
  184. * @param $account
  185. * User object
  186. */
  187. function hook_privatemsg_sql_unread_count_alter(&$fragment, $account) {
  188. }
  189. /**
  190. * @}
  191. */
  192. /**
  193. * @defgroup api API functions
  194. *
  195. * There are two different functions to send messages.
  196. * Either by starting a @link privatemsg_new_thread new thread @endlink
  197. * or @link privatemsg_reply reply @endlink to an existing thread.
  198. *
  199. * There is also a function which returns a link to the privatemsg new message
  200. * form with the recipient pre-filled if the user is allowed to.
  201. * privatemsg_get_link().
  202. */
  203. /**
  204. * @defgroup message_hooks Message hooks
  205. * All message-level hooks look like hook_privatemsg_message_op,
  206. * where op is one of the following:
  207. * - @link hook_privatemsg_message_load load @endlink: Called when a full
  208. * message is loaded similiar to nodeapi_load, new values can be returned and
  209. * will be added to $message, parameter: $message
  210. * - @link hook_privatemsg_message_validate validate @endlink: Validation,
  211. * before the message is sent/saved. Return validation errors as array,
  212. * parameter: $message, $form = FALSE
  213. * - @link hook_privatemsg_message_presave_alter presave_alter @endlink: Last
  214. * changes to $message before the message is saved, parameter: $message
  215. * - @link hook_privatemsg_message_insert insert @endlink: message has been
  216. * saved, $message has been updated with the mid and thread_id,
  217. * parameter: $message
  218. * - @link hook_privatemsg_message_delete delete @endlink: the message is
  219. * going to be deleted, parameter: $message
  220. * - @link hook_privatemsg_message_view_alter view_alter @endlink: the message
  221. * is going to be displayed, parameter: $vars
  222. * - @link hook_privatemsg_message_recipient_change recipient changed @endlink:
  223. * a recipient is added or removed from/to a message.
  224. *
  225. * In hooks with _alter suffix, $message is by reference.
  226. *
  227. * $message is an array, with all the relevant information about the message.
  228. * The information in there can be changed/extended by modules, but looks
  229. * typically like this:
  230. * @code
  231. * array (
  232. * 'mid' => 3517, // message id, identifies a message
  233. * 'author' => 27, // author id
  234. * 'subject' => 'raclebugav', // Message subject
  235. * 'body' => 'bla bla', // Body of the message
  236. * 'timestamp' => 351287003, // unix timestamp, creation time
  237. * 'is_new' => 0, // If the message has been read by the user
  238. * 'thread_id' => 3341, // thread id, this is actually the mid from the first
  239. * message of the thread
  240. * )
  241. * @endcode
  242. */
  243. /**
  244. * @addtogroup message_hooks
  245. * @{
  246. */
  247. /**
  248. * Is called after the message has been loaded.
  249. *
  250. * Return data will be merged with the $message array.
  251. *
  252. * @param $message
  253. * Message array
  254. */
  255. function hook_privatemsg_message_load($message) {
  256. return array('my_key' => 'my_value');
  257. }
  258. /**
  259. * Is called when a message is flushed.
  260. *
  261. * The message will be deleted from the database, remove any related data here.
  262. *
  263. * @param $message
  264. * Message array
  265. */
  266. function hook_privatemsg_message_flush($message) {
  267. }
  268. /**
  269. * Validate a message before it is sent/saved in the database.
  270. *
  271. * Validation errors can be returned, either as a string or as array when there
  272. * are multiple errors. If the $form flag is set, errors should be reported
  273. * with form_set_error instead.
  274. *
  275. * @todo adapt api return value changes
  276. *
  277. * @param $message
  278. * Message array
  279. */
  280. function hook_privatemsg_message_validate($message, $form = FALSE) {
  281. global $_privatemsg_invalid_recipients;
  282. $_privatemsg_invalid_recipients = array();
  283. $errors = array();
  284. foreach ($message['recipients'] as $recipient) {
  285. if ($recipient->name == 'blocked user') {
  286. $_privatemsg_invalid_recipients[] = $recipient->uid;
  287. $errors[] = t('%name has chosen to not recieve any more messages from you.', array('%name' => privatemsg_recipient_format($recipient, array('plain' => TRUE))));
  288. }
  289. }
  290. }
  291. /**
  292. * Change the message before it is stored.
  293. *
  294. * Alter the message, for example remove recipients that have been detected as
  295. * invalid or forbidden in the validate hook.
  296. *
  297. * @param $message
  298. * Message array
  299. */
  300. function hook_privatemsg_message_presave_alter(&$message) {
  301. // delete recipients which have been marked as invalid
  302. global $_privatemsg_invalid_recipients;
  303. foreach ($_privatemsg_invalid_recipients as $invalid) {
  304. unset($message['recipients'][$invalid]);
  305. }
  306. }
  307. /**
  308. * Act on the $vars before a message is displayed.
  309. *
  310. * This is called in the preprocess hook of the privatemsg-view template.
  311. * The $message data is aviable in $vars['message'].
  312. *
  313. * @param $var
  314. * Template variables
  315. */
  316. function hook_privatemsg_message_view_alter(&$var) {
  317. // add a link to each message
  318. $vars['message_links'][] = array('title' => t('My link'), 'href' => '/path/to/my/action/'. $vars['message']['mid']);
  319. }
  320. /**
  321. * This hook is executed after the message has been saved.
  322. *
  323. * $message is updated with mid and thread id. Use this hook to store data,
  324. * that needs to point to the saved message for example attachments.
  325. *
  326. * @param $message
  327. * Message array
  328. */
  329. function hook_privatemsg_message_insert($message) {
  330. _mymodule_save_data($message['mid']);
  331. }
  332. /**
  333. * This hook is invoked when a recipient is added to a message.
  334. *
  335. * Since the hook might be invoked hundreds of times during batch or cron, only
  336. * ids are passed and not complete user/message objects.
  337. *
  338. * @param $mid
  339. * Id of the message.
  340. * @param $thread_id
  341. * Id of the thread the message belongs to.
  342. * @param $recipient_id
  343. * Recipient id, a user id if type is user or hidden.
  344. * @param $type
  345. * Type of the recipient.
  346. * @param $added
  347. * TRUE if the recipient is added, FALSE if he is removed.
  348. */
  349. function hook_privatemsg_message_recipient_changed($mid, $thread_id, $recipient_id, $type, $added) {
  350. if ($added && ($type == 'user' || $type == 'hidden')) {
  351. privatemsg_filter_add_tags(array($thread_id), variable_get('privatemsg_filter_inbox_tag', ''), (object)array('uid' => $recipient));
  352. }
  353. }
  354. /**
  355. * @}
  356. */
  357. /**
  358. * @defgroup generic_hooks Generic Hooks
  359. * @{
  360. *
  361. * Some generic hooks that can't be categorized.
  362. */
  363. /**
  364. * Check if the author can send a message to the recipients.
  365. *
  366. * This can be used to limit who can write whom based on other modules and/or
  367. * settings.
  368. *
  369. * @param $author
  370. * Author of the message to be sent
  371. * @param $recipients
  372. * Recipient of the message
  373. * @param $context
  374. * Additional information. Can contain the thread_id to indicate that this is
  375. * a reply on an existing thread.
  376. * @return
  377. * An indexed array of arrays with the keys recipient ({type}_{key}) and
  378. * message (The reason why the recipient has been blocked).
  379. */
  380. function hook_privatemsg_block_message($author, $recipients, $context = array()) {
  381. $blocked = array();
  382. foreach($recipients as $recipient_id => $recipient) {
  383. // Deny/block if the recipient type is role and the account does not have
  384. // the necessary permission.
  385. if ($recipient->type == 'role' && $recipient->recipient == 2) {
  386. $blocked[] = array(
  387. 'recipient' => $recipient_id,
  388. 'message' => t('Not allowed to write private messages to the role authenticated user'),
  389. );
  390. }
  391. }
  392. return $blocked;
  393. }
  394. /**
  395. * Add content to the view thread page.
  396. *
  397. * @param $content
  398. * Render-able array of the content of the page.
  399. * @param $thread
  400. * Thread object which contains the messages and other information about
  401. * the thread.
  402. */
  403. function hook_privatemsg_view_messages_alter($content, $thread) {
  404. if (privatemsg_user_access('tag private messages')) {
  405. $content['tags'] = privatemsg_filter_show_tags($thread['thread_id'], !empty($_GET['show_tags_form']));
  406. }
  407. }
  408. /**
  409. * List of possible templates.
  410. */
  411. function hook_privatemsg_view_template() {
  412. }
  413. /**
  414. * Expose operations/actions which can be executed on threads.
  415. *
  416. * Return an array of operations to privatemsg, the key of each operation is the
  417. * operation key or name.
  418. *
  419. * @see _privatemsg_action_form()
  420. * @see privatemsg_list_submit()
  421. */
  422. function hook_privatemsg_thread_operations() {
  423. return array(
  424. 'operation key' => array(
  425. 'label' => 'Label of the operation. Only use this if the operation
  426. should be displayed automatically in the action form',
  427. 'callback' => 'privatemsg_thread_change_status', // Function callback that will be executed.
  428. 'callback arguments' => array('status' => PRIVATEMSG_READ), // Additional arguments to above function
  429. 'undo callback' => 'privatemsg_thread_change_status', // Provide a function which can "undo" the operation. Optional.
  430. 'undo callback arguments' => array('status' => PRIVATEMSG_UNREAD), // Additional arguments to above function.
  431. ),
  432. );
  433. }
  434. /**
  435. * Allows to alter the found autocompletions.
  436. *
  437. * @param $matches
  438. * Array of matching recipient objects.
  439. * @param $names
  440. * Array of names that are already in the list.
  441. * @param $fragment
  442. * Fragment that is currently searched for.
  443. */
  444. function hook_privatemsg_autocomplete_alter(&$matches, $names, $fragment) {
  445. // Remove all types other than user if accessed through
  446. // messages/user/autocomplete.
  447. if (arg(1) == 'user') {
  448. foreach ($matches as $id => $match) {
  449. if ($match->type != 'user') {
  450. unset($matches[$id]);
  451. }
  452. }
  453. }
  454. }
  455. /**
  456. * Allows to alter found recipient types for a given string.
  457. *
  458. * @param $matches
  459. * Array of matching recipient objects.
  460. * @param $string
  461. * String representation of the recipient.
  462. */
  463. function hook_privatemsg_name_lookup_matches(&$matches, $string) {
  464. }
  465. /**
  466. * Allows response to a successful operation.
  467. *
  468. * @param $operation
  469. * The operation that was executed.
  470. * @param $threads
  471. * An array which contains the thread ids on which the operation
  472. * has been executed.
  473. * @param $account
  474. * An user account object if an other user than the currrently logged in is
  475. * affected.
  476. *
  477. * @see hook_privatemsg_thread_operations()
  478. * @see privatemsg_operation_execute()
  479. */
  480. function hook_privatemsg_operation_executed($operation, $threads, $account = NULL) {
  481. }
  482. /**
  483. * Allows response to a status change.
  484. *
  485. * @param $pmid
  486. * Message id.
  487. * @param $status
  488. * Either PRIVATEMSG_READ or PRIVATEMSG_UNREAD.
  489. * @param $account
  490. * User object, defaults to the current user.
  491. *
  492. * @see privatemsg_message_change_status()
  493. */
  494. function hook_privatemsg_message_status_changed($pmid, $status, $account) {
  495. }
  496. /**
  497. * Allows response to a deleted change.
  498. *
  499. * Modules implementing this hook should be aware that messages are only
  500. * marked as deleted and not removed from the database. They will only
  501. * eventually be deleted by the flushing.
  502. *
  503. * Therefore, modules should not delete data in this hook but in
  504. * hook_privatemsg_message_flush().
  505. *
  506. * @param $mid
  507. * Message id.
  508. * @param $deleted
  509. * TRUE when the message was marked as deleted, FALSE when marked as not
  510. * deleted.
  511. * @param $account
  512. * User object, if NULL then the message was marked as deleted for all users.
  513. *
  514. * @see privatemsg_message_change_delete()
  515. * @see privatemsg_thread_change_delete()
  516. *
  517. */
  518. function hook_privatemsg_message_status_delete($mid, $deleted, $account) {
  519. }
  520. /**
  521. * @}
  522. */
  523. /**
  524. * @defgroup types Types of recipients
  525. *
  526. * It is possible to define other types of recipients than the usual single
  527. * user. These types are defined through a hook and a few callbacks and are
  528. * stored in the {pm_index} table for each recipient entry.
  529. *
  530. * The combination of a recipient type and recipient ID defines a unique
  531. * recipient. Note: The recipient ID must be an integer; in older versions,
  532. * this was simply a user ID.
  533. *
  534. * This feature is usually used to define groups of recipients. Privatemsg
  535. * comes with the privatemsg_roles sub-module, which allows to send messages to
  536. * all members of a specific group.
  537. *
  538. * When sending a new message with a recipient type other than user, Privatemsg
  539. * only inserts a single entry for that recipient type. However, when looking
  540. * for messages for a user, Privatemsg only looks for recipient types user and
  541. * hidden. To fill the gap, Privatemsg defines three ways how a non-user
  542. * type is converted to hidden recipient entries.
  543. *
  544. * - For small recipient types (by default <100 recipients, configurable), the
  545. * entries are added directly after saving the original private message.
  546. * - When sending messages through the UI, bigger recipient types are handled
  547. * with batch API.
  548. * - For messages sent by the API, the hidden recipients are generated during
  549. * cron runs.
  550. *
  551. * Once all hidden recipients are added, the original recipient type is marked
  552. * as read so Privatemsg knows that he has been processed.
  553. *
  554. * Privatemsg defines the following types:
  555. *
  556. * - user: This is the default recipient type which is used for a single user.
  557. * - hidden: Used to add internal recipient entries for other recipient types.
  558. * - role: The sub-module privatemsg_roles defines an additional type called
  559. * role. This allows to send messages to all members of a role.
  560. *
  561. * To implement a new type, the following hooks need to be implemented. Note
  562. * that most of these hooks can also be used alone for other functionality than
  563. * defining recipient types.
  564. *
  565. * - hook_privatemsg_recipient_type_info() - Tell Privatemsg about your
  566. * recipient type(s).
  567. * - hook_privatemsg_name_lookup() - Convert a string to an
  568. * recipient object
  569. *
  570. * Additionaly, there is also a hook_privatemsg_recipient_type_info_alter() that
  571. * allows to alter recipient type definitions.
  572. */
  573. /**
  574. * @addtogroup types
  575. * @{
  576. */
  577. /**
  578. * This hook is used to tell privatemsg about the recipient types defined by a
  579. * module. Each type consists of an array keyed by the internal recipient type
  580. * name and the following keys must be defined.
  581. *
  582. * * name: Translated name of the recipient type.
  583. * * description: A short description of how to send messages to to that
  584. * recipient type. This is displayed below the To: field when sending a
  585. * message.
  586. * * load: A callback function that can load recipients based on their id,
  587. * example: privatemsg_roles_load_multiple().
  588. * * format: Theme function to format the recipient before displaying. Must be
  589. * defined with hook_theme(), example: theme_privatemsg_roles_format().
  590. * * autocomplete: Function callback to return possible autocomplete matches,
  591. * example: privatemsg_roles_autocomplete().
  592. * * generate recipients: Function callback to return user ids which belong to a
  593. * recipient type, example: privatemsg_roles_load_recipients().
  594. * * max: Function callback to return the highest user id of a recipient type,
  595. * example: privatemsg_roles_count_recipients().
  596. * * write access: Optionally define a permission which controls write access
  597. * to that recipient type.
  598. * * write callback: Optionally define a callback function that returns an
  599. * access decision (allow = TRUE, deny = FALSE) for whether the current user
  600. * can write to recipients of the given recipient type.
  601. * * view access: Optionally define a permission which controls if the user is
  602. * able to see the recipient when he is looking at a thread.
  603. * * view callback: Optionally define a callback function that returns an
  604. * access decision (allow = TRUE, deny = FALSE) for whether the current user
  605. * can see recipients of the given recipient type.
  606. */
  607. function hook_privatemsg_recipient_type_info() {
  608. return array(
  609. 'role' => array(
  610. 'name' => t('Role'),
  611. 'description' => t('Enter the name of a role to write a message to all users which have that role. Example: authenticated user.'),
  612. 'load' => 'privatemsg_roles_load_multiple',
  613. 'format' => 'privatemsg_roles_format',
  614. 'autocomplete' => 'privatemsg_roles_autocomplete',
  615. 'generate recipients' => 'privatemsg_roles_load_recipients',
  616. 'count' => 'privatemsg_roles_count_recipients',
  617. 'write callback' => 'privatemsg_roles_write_access',
  618. 'view access' => 'view roles recipients',
  619. ),
  620. );
  621. }
  622. /**
  623. * Hook which allows to look up a user object.
  624. *
  625. * You can try to look up a user object based on the information passed to the
  626. * hook. The first hook that successfully looks up a specific string wins.
  627. *
  628. * Therefore, it is important to only return something if you can actually look
  629. * up the string.
  630. */
  631. function hook_privatemsg_name_lookup($string) {
  632. $result = db_query("SELECT *, rid AS recipient FROM {role} WHERE name = '%s'", trim($role));
  633. if ($role = db_fetch_object($result)) {
  634. $role->type = 'role';
  635. return $role;
  636. }
  637. }
  638. /**
  639. * Allows to alter the defined recipient types.
  640. *
  641. * @param $types
  642. * Array with the recipient types.
  643. *
  644. * @see hook_privatemsg_recipient_type_info()
  645. */
  646. function hook_privatemsg_recipient_type_info_alter(&$types) {
  647. }
  648. /**
  649. * @}
  650. */
  651. /**
  652. * Declare headers for message listings.
  653. *
  654. * @return
  655. * An array keyed by an identifier. All header definition keys for theme_table
  656. * and tablesortort_sql() and the following additional keys:
  657. * - #enabled: TRUE if the header should be enabled by default. FALSE by
  658. * default.
  659. * - #locked: TRUE if it the header should be locked and can not be
  660. * enabled or disabled in the user interface.
  661. * - #weight: The default weight which can be changed in the user interface.
  662. * - #title: A title used in the administrative user interface. Defaults to
  663. * data.
  664. * - #access: Control if the header is accessible, TRUE or FALSE.
  665. * - #theme: Optionally define a theme function for the field. Defaults to
  666. * 'privatemsg_list_field_$key'.
  667. *
  668. * @see theme_table
  669. * @ingroup theming
  670. */
  671. function hook_privatemsg_header_info() {
  672. return array(
  673. 'subject' => array(
  674. 'data' => t('Subject'),
  675. 'field' => 'subject',
  676. 'class' => 'privatemsg-header-subject',
  677. '#enabled' => TRUE,
  678. '#locked' => TRUE,
  679. '#weight' => -20,
  680. ),
  681. );
  682. }
  683. /**
  684. * Alter the defined header structure.
  685. *
  686. * @param $headers
  687. * All headers returned by hook_privatemsg_header_info().
  688. */
  689. function hook_privatemsg_header_info_alter(&$headers) {
  690. }

Functions

Namesort descending Description
hook_privatemsg_autocomplete_alter Allows to alter the found autocompletions.
hook_privatemsg_block_message Check if the author can send a message to the recipients.
hook_privatemsg_header_info Declare headers for message listings.
hook_privatemsg_header_info_alter Alter the defined header structure.
hook_privatemsg_message_flush Is called when a message is flushed.
hook_privatemsg_message_insert This hook is executed after the message has been saved.
hook_privatemsg_message_load Is called after the message has been loaded.
hook_privatemsg_message_presave_alter Change the message before it is stored.
hook_privatemsg_message_recipient_changed This hook is invoked when a recipient is added to a message.
hook_privatemsg_message_status_changed Allows response to a status change.
hook_privatemsg_message_status_delete Allows response to a deleted change.
hook_privatemsg_message_validate Validate a message before it is sent/saved in the database.
hook_privatemsg_message_view_alter Act on the $vars before a message is displayed.
hook_privatemsg_name_lookup Hook which allows to look up a user object.
hook_privatemsg_name_lookup_matches Allows to alter found recipient types for a given string.
hook_privatemsg_operation_executed Allows response to a successful operation.
hook_privatemsg_recipient_type_info This hook is used to tell privatemsg about the recipient types defined by a module. Each type consists of an array keyed by the internal recipient type name and the following keys must be defined.
hook_privatemsg_recipient_type_info_alter Allows to alter the defined recipient types.
hook_privatemsg_sql_autocomplete_alter Query to search for autocomplete usernames.
hook_privatemsg_sql_list_alter Display a list of threads.
hook_privatemsg_sql_load_alter Query definition to load a message.
hook_privatemsg_sql_messages_alter Query definition to load messages of one or multiple threads.
hook_privatemsg_sql_participants_alter Alter the query that loads the participants of a thread.
hook_privatemsg_sql_unread_count_alter Loads all unread messages of a user (only the count query is used).
hook_privatemsg_thread_operations Expose operations/actions which can be executed on threads.
hook_privatemsg_view_messages_alter Add content to the view thread page.
hook_privatemsg_view_template List of possible templates.