Index: feedback.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/feedback/feedback.install,v retrieving revision 1.11 diff -u -p -r1.11 feedback.install --- feedback.install 14 Jan 2011 01:44:22 -0000 1.11 +++ feedback.install 14 Jan 2011 02:21:27 -0000 @@ -7,38 +7,66 @@ */ /** - * Implementation of hook_schema(). + * Implements hook_schema(). */ function feedback_schema() { $schema['feedback'] = array( - 'description' => t('Stores all feedback messages.'), + 'description' => 'Stores all feedback messages.', 'fields' => array( - 'fid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, - 'description' => t('The primary identifier for a feedback message.'), - ), - 'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - 'description' => t('The user id of the author of a feedback message.'), - ), - 'status' => array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - 'description' => t('The status of a feedback message.'), - ), - 'message' => array('type' => 'text', 'size' => 'big', 'not null' => TRUE, - 'description' => t('The actual feedback message.'), - ), - 'location' => array('type' => 'text', 'not null' => TRUE, - 'description' => t('The internal Drupal path of the page the feedback message was submitted on.'), - ), - 'location_masked' => array('type' => 'text', 'not null' => TRUE, - 'description' => t('The masked Drupal path of the page the feedback message was submitted on.'), - ), - 'url' => array('type' => 'text', 'not null' => TRUE, - 'description' => t('The absolute URL of the page the feedback message was submitted on.'), - ), - 'useragent' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, - 'description' => t('The user agent of the feedback message author.'), - ), - 'timestamp' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, - 'description' => t('The UNIX timestamp when the feedback message was created.'), + 'fid' => array( + 'description' => 'Feedback message ID.', + 'type' => 'serial', + 'unsigned' => TRUE, + 'not null' => TRUE, + ), + 'uid' => array( + 'description' => 'User ID of the feedback message author.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), + 'status' => array( + 'description' => 'Feedback status (0 = new, 1 = processed).', + 'type' => 'int', + 'size' => 'tiny', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), + 'message' => array( + 'description' => 'The feedback message.', + 'type' => 'text', + 'size' => 'big', + 'not null' => TRUE, + ), + 'location' => array( + 'description' => 'System path of the originating page.', + 'type' => 'text', + 'not null' => TRUE, + ), + 'location_masked' => array( + 'description' => 'Untranslated system path of the originating page.', + 'type' => 'text', + 'not null' => TRUE, + ), + 'url' => array( + 'description' => 'Absolute URL of the originating page.', + 'type' => 'text', + 'not null' => TRUE, + ), + 'useragent' => array( + 'description' => 'User agent of the feedback message author.', + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + ), + // @todo Rename to created. Also add 'changed'. + 'timestamp' => array( + 'description' => 'UNIX timestamp of the feedback message creation date.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, ), ), 'primary key' => array('fid'), @@ -51,29 +79,39 @@ function feedback_schema() { } /** - * Implementation of hook_uninstall(). + * Implements hook_uninstall(). */ function feedback_uninstall() { - db_query("DELETE FROM {variable} WHERE name LIKE 'feedback_%%'"); + db_delete('variable') + ->condition('name', 'feedback_%', 'LIKE') + ->execute(); } /** * Change fid into type serial field. */ function feedback_update_6100() { - $ret = array(); - db_drop_primary_key($ret, 'feedback'); - db_change_field($ret, 'feedback', 'fid', 'fid', array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), array('primary key' => array('fid'))); - return $ret; + db_drop_primary_key('feedback'); + db_change_field('feedback', 'fid', 'fid', array( + 'type' => 'serial', + 'unsigned' => TRUE, + 'not null' => TRUE, + ), array( + 'primary key' => array('fid'), + )); } /** * Add column for absolute URL. */ function feedback_update_6101() { - $ret = array(); - db_add_field($ret, 'feedback', 'url', array('type' => 'text', 'not null' => TRUE)); - $ret[] = update_sql("UPDATE {feedback} SET url = location"); - return $ret; + db_add_field('feedback', 'url', array( + 'type' => 'text', + 'not null' => TRUE, + )); + // Set 'url' to the value of 'location' for all existing entries. + db_update('feedback') + ->expression('url', 'location') + ->execute(); } Index: feedback.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/feedback/feedback.module,v retrieving revision 1.81 diff -u -p -r1.81 feedback.module --- feedback.module 14 Jan 2011 01:53:55 -0000 1.81 +++ feedback.module 14 Jan 2011 02:06:16 -0000 @@ -7,7 +7,7 @@ */ /** - * Implementation of hook_perm(). + * Implements hook_permission(). */ function feedback_permission() { return array( @@ -23,7 +23,7 @@ function feedback_permission() { } /** - * Implementation of hook_theme(). + * Implements hook_theme(). */ function feedback_theme() { return array( @@ -34,7 +34,7 @@ function feedback_theme() { } /** - * Implementation of hook_menu(). + * Implementas hook_menu(). */ function feedback_menu() { $items['admin/reports/feedback'] = array( @@ -49,7 +49,7 @@ function feedback_menu() { } /** - * Implementation of hook_init(). + * Implements hook_init(). */ function feedback_init() { if (user_access('access feedback form')) { @@ -60,7 +60,7 @@ function feedback_init() { } /** - * Implementation of hook_block_info(). + * Implements hook_block_info(). */ function feedback_block_info() { $blocks['form'] = array( @@ -70,7 +70,7 @@ function feedback_block_info() { } /** - * Implementation of hook_block_view(). + * Implements hook_block_view(). */ function feedback_block_view($delta = '') { $block = array(); @@ -87,7 +87,7 @@ function feedback_block_view($delta = '' } /** - * Implementation of hook_page_build(). + * Implements hook_page_build(). */ function feedback_page_build(&$page) { if (user_access('access feedback form') && $_GET['q'] != 'admin/reports/feedback') { @@ -109,7 +109,7 @@ function feedback_page_build(&$page) { } /** - * Form builder function for a user feedback form. + * Form constructor for the feedback form. */ function feedback_form($form, &$form_state) { $form['#attributes']['class'] = array('feedback-form'); @@ -163,6 +163,9 @@ function feedback_form($form, &$form_sta return $form; } +/** + * Form submission handler for feedback_form(). + */ function feedback_form_submit($form, &$form_state) { $entry = new stdClass(); $entry->message = $form_state['values']['message']; @@ -179,7 +182,7 @@ function feedback_form_submit($form, &$f } /** - * Format a feedback entry. + * Returns HTML for a feedback entry. * * @param $entry * A feedback object. @@ -200,7 +203,7 @@ function feedback_format_message($entry) } /** - * Loads a feedback entry object. + * Loads a feedback entry from the database. * * @param $fid * Integer specifying the feedback ID to load. @@ -277,13 +280,14 @@ function feedback_save($entry) { if (!isset($entry->useragent)) { $entry->useragent = $_SERVER['HTTP_USER_AGENT']; } - drupal_write_record('feedback', $entry); + $status = drupal_write_record('feedback', $entry); module_invoke_all('feedback_insert', $entry); } else { - drupal_write_record('feedback', $entry, 'fid'); + $status = drupal_write_record('feedback', $entry, 'fid'); module_invoke_all('feedback_update', $entry); } + return $status; } /** @@ -292,7 +296,7 @@ function feedback_save($entry) { * @param $fid * A feedback entry ID. */ -function feedback_delete() { +function feedback_delete($fid) { feedback_delete_multiple(array($fid)); } @@ -324,6 +328,8 @@ function feedback_delete_multiple($fids) * An internal Drupal path, f.e. 'user/123/edit'. * @return * A 'masked' path, for above example 'user/%/edit'. + * + * @todo Use the untranslated patch of menu_get_item() instead. */ function feedback_mask_path($path) { return preg_replace('@/\d+@', '/%', $path);