瀏覽代碼

- add upgrade suggestions from deadwood.module

Frederic G. Marand 15 年之前
父節點
當前提交
b4f18cbc06
共有 1 個文件被更改,包括 151 次插入4 次删除
  1. 151 4
      qbf.module

+ 151 - 4
qbf.module

@@ -6,13 +6,106 @@
  * This module allows node modules to add a query by form tab for their node
  * types to the default search form
  *
- * @copyright 2008 Ouest Systemes Informatiques (OSInet)
+ * @copyright 2008-2009 Ouest Systemes Informatiques (OSInet)
  * @author Frederic G. MARAND
- * @license CeCILL 2.0
+ * @license Licensed under the CeCILL 2.0 and the General Public Licence version 2 or later
  * @package QBF
  */
 
-// $Id: qbf.module,v 1.9.4.1 2009-03-17 10:59:14 marand Exp $
+// $Id: qbf.module,v 1.9.4.2 2009-03-17 12:59:28 marand Exp $
+
+// ======== D6 LIMIT ==================================================================================================
+/* TODO New hook_mail implementation
+   Because of changes to drupal_mail function, you need to move the variables
+   setup and string replace commands into the hook_mail implementation and then
+   call drupal_mail with the name of the module which contains this
+   implementation, the mailkey, the recipient, the language of the user the mail
+   goes to and some arbitrary parameters. */
+
+/* TODO db_next_id() is gone, and replaced as db_last_insert_id()
+   Since db_next_id() introduce some problems, and the use of this function
+   can be replaced by database level auto increment handling, db_next_id()
+   is now gone and replaced as db_last_insert_id() with help of serial type
+   under Schema API (check out http://drupal.org/node/149176 for more details).
+   Please refer to drupal_write_record() as demonstration. */
+
+/* TODO FormAPI image buttons are now supported.
+   FormAPI now offers the 'image_button' element type, allowing developers to
+   use icons or other custom images in place of traditional HTML submit buttons.
+
+$form['my_image_button'] = array(
+  '#type'         => 'image_button',
+  '#title'        => t('My button'),
+  '#return_value' => 'my_data',
+  '#src'          => 'my/image/path.jpg',
+); */
+
+/* TODO Check node access before emailing content
+   Modules like Organic Groups and Project Issue send the same content as an
+   email notifications to many users. They should now be using the new 3rd
+   parameter to node_access() to check access on the content before emailing it.
+   Note that db_rewrite_sql() provodes no protection because the recipient is not
+   the logged in user who is receiving the content. */
+
+/* TODO hook_user('view')
+   The return value of hook_user('view') has changed, to match the process that
+   nodes use for rendering. Modules should add their custom HTML to
+   $account->content element. Further, this HTML should be in the form that
+   drupal_render() recognizes. */
+
+/* TODO Node previews and adding form fields to the node form.
+   There is a subtle but important difference in the way node previews (and other
+   such operations) are carried out when adding or editing a node. With the new
+   Forms API, the node form is handled as a multi-step form. When the node form
+   is previewed, all the form values are submitted, and the form is rebuilt with
+   those form values put into $form['#node']. Thus, form elements that are added
+   to the node form will lose any user input unless they set their '#default_value'
+   elements using this embedded node object. */
+
+/* TODO New user_mail_tokens() method may be useful.
+   user.module now provides a user_mail_tokens() function to return an array
+   of the tokens available for the email notification messages it sends when
+   accounts are created, activated, blocked, etc. Contributed modules that
+   wish to make use of the same tokens for their own needs are encouraged
+   to use this function. */
+
+/* TODO
+   There is a new hook_watchdog in core. This means that contributed modules
+   can implement hook_watchdog to log Drupal events to custom destinations.
+   Two core modules are included, dblog.module (formerly known as watchdog.module),
+   and syslog.module. Other modules in contrib include an emaillog.module,
+   included in the logging_alerts module. See syslog or emaillog for an
+   example on how to implement hook_watchdog.
+function example_watchdog($log = array()) {
+  if ($log['severity'] == WATCHDOG_ALERT) {
+    mysms_send($log['user']->uid,
+      $log['type'],
+      $log['message'],
+      $log['variables'],
+      $log['severity'],
+      $log['referer'],
+      $log['ip'],
+      format_date($log['timestamp']));
+  }
+} */
+
+/* TODO Implement the hook_theme registry. Combine all theme registry entries
+   into one hook_theme function in each corresponding module file.
+function qbf_theme() {
+  return array(
+  );
+}; */
+
+
+/* TODO
+   An argument for replacements has been added to format_plural(),
+   escaping and/or theming the values just as done with t().*/
+
+/* TODO $form['#base'] is gone
+   In FormAPI, many forms with different form_ids can share the same validate,
+   submit, and theme handlers. This can be done by manually populating the
+   $form['#submit'], $form['#validate'], and $form['#theme'] elements with
+   the proper function names. */
 
 /**
  * Saved error reporting level.
@@ -102,6 +195,8 @@ define('QBF_DEF_NOTIFY_DELETE',      FALSE);
  * @return array
  */
 function qbf_transform_form($form_id) {
+// @todo GW:  function qbf_transform_form(&$form_state, $form_id) {
+
   $ar_args = func_get_args();
 //dsm(array('qtf' => $ar_args));
   // Fetch the basic form and rename it, passing it the caller's arguments
@@ -465,6 +560,17 @@ function qbf_query_load($qid) {
  * @return string
  */
 function qbf_submit($form_id, $form_values) {
+/*
+
+function qbf_submit($form, &$form_state) {
+/* @TODO GW The 'op' element in the form values is deprecated.
+   Each button can have #validate and #submit functions associated with it.
+   Thus, there should be one button that submits the form and which invokes
+   the normal form_id_validate and form_id_submit handlers. Any additional
+   buttons which need to invoke different validate or submit functionality
+   should have button-specific functions.
+  switch ($form_state['values']['op']) { */
+
   switch ($form_values['op']) {
     case t('Search'):
       $ret = FALSE;
@@ -472,14 +578,20 @@ function qbf_submit($form_id, $form_values) {
 
     case t('Save query'):
       _qbf_save($form_id, $form_values);
+//@TODO GW _qbf_save($form_state['values']['form_id'], $form_state['values']);
       drupal_set_message(t('Your query was saved as "@name".',
         array('@name' => $form_values['save-name'])));
-      global $user;
+//@TODO GW _qbf_save($form_state['values']['form_id'], $form_state['values']);
+        global $user;
       $ret = "user/$user->uid/edit/job";;
       break;
   }
   //dsm(array('QS' => $form_values));
   return $ret;
+/* @todo GW
+  //dsm(array('QS' => $form_state['values']));
+  $form_state['redirect'] = $ret;
+*/
 }
 
 /**
@@ -524,6 +636,9 @@ function _qbf_save($form_id, $form_values) {
     $ret = 0;
   }
   else {
+/* @TODO GW drupal_retrieve_form() now accepts a form_state parameter.
+    $form = drupal_retrieve_form($form_id, $form_state);
+*/
     $form = drupal_retrieve_form($form_id);
     drupal_prepare_form($form_id, $form);
     $name = $form_values['save-name'];
@@ -559,6 +674,26 @@ function _qbf_save($form_id, $form_values) {
  */
 function qbf_menu()
   {
+/* TODO
+   Non menu code that was placed in hook_menu under the '!$may_cache' block
+   so that it could be run during initialization, should now be moved to hook_init.
+   Previously we called hook_init twice, once early in the bootstrap process, second
+   just after the bootstrap has finished. The first instance is now called boot
+   instead of init.
+
+   In Drupal 6, there are now two hooks that can be used by modules to execute code
+   at the beginning of a page request. hook_boot() replaces hook_boot() in Drupal 5
+   and runs on each page request, even for cached pages. hook_boot() now only runs
+   for non-cached pages and thus can be used for code that was previously placed in
+   hook_menu() with $may_cache = FALSE:
+
+   Dynamic menu items under a '!$may_cache' block can often be simplified
+   to remove references to arg(n) and use of '%<function-name>' to check
+   conditions. See http://drupal.org/node/103114.
+
+   The title and description arguments should not have strings wrapped in t(),
+   because translation of these happen in a later stage in the menu system.
+*/
   $items = array();
   $admin_access  = array(QBF_PERM_ADMIN);
   $queror_access = array(QBF_PERM_QUERY);
@@ -612,6 +747,18 @@ function _qbf_query_delete($qid) {
     watchdog('qbf', $message, WATCHDOG_NOTICE, $link);
     if (variable_get(QBF_VAR_NOTIFY_DELETE, QBF_DEF_NOTIFY_DELETE) && $query->uid != $user->uid) {
       $ret = drupal_mail(__FUNCTION__, $user->mail, $message, $message, $user->mail);
+/* @todo GW
+//      $ret = drupal_mail(__FUNCTION__, $user->mail, $message, $message, $user->mail);
+      $ret = /* TODO Create a hook_mail($key, &$message, $params) function to generate
+      $ret = the message body when called by drupal_mail.
+      $ret = $account = array(); // Set this as needed
+      $ret = $language = user_preferred_language($account);
+      $ret = $object = array(); // Replace this as needed
+      $ret = $context['subject'] = $subject;
+      $ret = $context['body'] = $body;
+      $ret = $params = array('account' => $account, 'object' => $object, 'context' => $context);
+      $ret = drupal_mail('qbf', __FUNCTION__, $user->mail, $language, $params, $user->mail);
+*/
       $account = user_load(array('uid' => $query->uid));
       drupal_set_message(t('User !link has been informed', array
         (