? follow-D7-619276-1.patch
? follow-D7-619276-4.patch
Index: follow.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/follow/follow.module,v
retrieving revision 1.4
diff -u -p -r1.4 follow.module
--- follow.module	30 Oct 2009 21:13:50 -0000	1.4
+++ follow.module	30 Oct 2009 21:57:24 -0000
@@ -74,7 +74,7 @@ function follow_links_user_access($uid) 
 }
 
 /**
- * Implementation of hook_perm().
+ * Implementation of hook_permission().
  */
 function follow_permission() {
   return array(
@@ -117,83 +117,94 @@ function follow_theme() {
 }
 
 /**
- * Implementation of hook_block().
+ * Implementation of hook_block_info().
  */
-function follow_block($op = 'list', $delta = 'site', $edit = array()) {
-  if ($op == 'list') {
-    $blocks['site'] = array(
-      'info' => t('Follow Site'),
-      'cache' => BLOCK_CACHE_GLOBAL,
-    );
+function follow_block_info() {
+  $blocks['site'] = array(
+    'info' => t('Follow Site'),
+    'cache' => DRUPAL_CACHE_GLOBAL,
+  );
 
-    $blocks['user'] = array(
-      'info' => t('Follow User'),
-      'cache' => BLOCK_CACHE_PER_PAGE,
-    );
+  $blocks['user'] = array(
+    'info' => t('Follow User'),
+    'cache' => DRUPAL_CACHE_PER_PAGE,
+  );
 
-    return $blocks;
-  }
-  elseif ($op == 'configure') {
-    switch($delta) {
-      case 'site':
-        $form['follow_title'] = array(
-          '#type' => 'radios',
-          '#title' => t('Default block title'),
-          '#default_value' => variable_get('follow_site_block_title', FOLLOW_NAME),
-          '#options' => array(
-            FOLLOW_NAME => t('Follow @name on', array('@name' => variable_get('site_name', 'Drupal'))),
-            FOLLOW_ME => t('Follow me on'),
-            FOLLOW_US => t('Follow us on'),
-          ),
-        );
-        $form['follow_user'] = array(
-          '#type' => 'checkbox',
-          '#title' => t('User pages'),
-          '#description' => t('Should this block display on user profile pages?'),
-          '#default_value' => variable_get('follow_site_block_user', TRUE),
-        );
-        return $form;
+  return $blocks;
+}
 
-      case 'user':
-        $form['follow_title'] = array(
-          '#type' => 'radios',
-          '#title' => t('Default block title'),
-          '#default_value' => variable_get('follow_user_block_title', FOLLOW_NAME),
-          '#options' => array(
-            FOLLOW_NAME => t('Follow [username] on'),
-            FOLLOW_ME => t('Follow me on'),
-          ),
-        );
-        return $form;
-    }
+
+/**
+ * Implementation of hook_block_configure().
+ */
+function follow_block_configure($delta = '') {
+  switch($delta) {
+    case 'site':
+      $form['follow_title'] = array(
+        '#type' => 'radios',
+        '#title' => t('Default block title'),
+        '#default_value' => variable_get('follow_site_block_title', FOLLOW_NAME),
+        '#options' => array(
+          FOLLOW_NAME => t('Follow @name on', array('@name' => variable_get('site_name', 'Drupal'))),
+          FOLLOW_ME => t('Follow me on'),
+          FOLLOW_US => t('Follow us on'),
+        ),
+      );
+      $form['follow_user'] = array(
+        '#type' => 'checkbox',
+        '#title' => t('User pages'),
+        '#description' => t('Should this block display on user profile pages?'),
+        '#default_value' => variable_get('follow_site_block_user', TRUE),
+      );
+      return $form;
+
+    case 'user':
+      $form['follow_title'] = array(
+        '#type' => 'radios',
+        '#title' => t('Default block title'),
+        '#default_value' => variable_get('follow_user_block_title', FOLLOW_NAME),
+        '#options' => array(
+          FOLLOW_NAME => t('Follow [username] on'),
+          FOLLOW_ME => t('Follow me on'),
+        ),
+      );
+      return $form;
   }
-  elseif ($op == 'save') {
-    variable_set('follow_'. $delta .'_block_title', $edit['follow_title']);
-    if ($delta == 'site') {
-      variable_set('follow_site_block_user', $edit['follow_user']);
-    }
+}
+
+/**
+ * Implementation of hook_block_save().
+ */
+function follow_block_save($delta = '', $edit = array()) {
+  variable_set('follow_'. $delta .'_block_title', $edit['follow_title']);
+  if ($delta == 'site') {
+    variable_set('follow_site_block_user', $edit['follow_user']);
   }
-  elseif ($op == 'view') {  
-    switch ($delta) {
-      case 'site':
-        if (($content = _follow_block_content())
-            && (variable_get('follow_site_block_user', TRUE) || !(arg(0) == 'user' && is_numeric(arg(1))))) {
-          return array(
-            'subject' => _follow_block_subject(),
-            'content' => $content,
-          );
-        }
-        break;
-      case 'user':
-        $uid = arg(1);
-        if (arg(0) == 'user' && is_numeric($uid) && ($content = _follow_block_content($uid))) {
-          return array(
-            'subject' => _follow_block_subject($uid),
-            'content' => $content,
-          );
-        }
-        break;
-    }
+}
+
+/**
+ * Implementation of hook_block_view().
+ */
+function follow_block_view($delta = '') {
+  switch ($delta) {
+    case 'site':
+      if (($content = _follow_block_content())
+          && (variable_get('follow_site_block_user', TRUE) || !(arg(0) == 'user' && is_numeric(arg(1))))) {
+        return array(
+          'subject' => _follow_block_subject(),
+          'content' => $content,
+        );
+      }
+      break;
+    case 'user':
+      $uid = arg(1);
+      if (arg(0) == 'user' && is_numeric($uid) && ($content = _follow_block_content($uid))) {
+        return array(
+          'subject' => _follow_block_subject($uid),
+          'content' => $content,
+        );
+      }
+      break;
   }
 }
 
@@ -289,18 +300,19 @@ function theme_follow_links($variables) 
  *
  * @ingroup themable
  */
-function theme_follow_link($link, $title) {
+function theme_follow_link($variables) {
+  $link = $variables['link'];
+  $title = $variables['title'];
   $classes = array();
   $classes[] = 'follow-link';
   $classes[] = "follow-link-{$link->name}";
   $classes[] = $link->uid ? 'follow-link-user' : 'follow-link-site';
-  $attributes = drupal_attributes(array(
+  $attributes = array(
     'class' => implode(' ', $classes),
-    'href' => $link->url,
     'title' => follow_link_title($link->uid) .' '. $title,
-  ));
+  );
 
-  return "<a$attributes>$title</a>\n";
+  return l($title, $link->url, array('attributes' => $attributes)) . "\n";
 }
 
 /**
@@ -317,7 +329,7 @@ function _follow_block_config_links($uid
   if ($uid == 0 && user_access('edit site follow links')) {
     $links['follow_edit'] = array(
       'title' => t('Edit'),
-      'href' => 'admin/build/follow',
+      'href' => 'admin/config/services/follow',
       'query' => drupal_get_destination(),
     );
   }
@@ -332,7 +344,7 @@ function _follow_block_config_links($uid
   if (user_access('administer blocks')) {
     $links['follow_configure'] = array(
       'title' => t('Configure'),
-      'href' => $uid ? 'admin/build/block/configure/follow/user' : 'admin/build/block/configure/follow/site',
+      'href' => $uid ? 'admin/structure/block/configure/follow/user' : 'admin/structure/block/configure/follow/site',
       'query' => drupal_get_destination(),
     );
   }
@@ -468,11 +480,11 @@ function theme_follow_links_form($form) 
     if (isset($form['follow_links'][$key]['weight'])) {
       $row[] = drupal_render($form['follow_links'][$key]['lid']) . drupal_render($form['follow_links'][$key]['name']);
       $row[] = drupal_render($form['follow_links'][$key]['url']);
-  
+
       // Now, render the weight row.
       $form['follow_links'][$key]['weight']['#attributes']['class'] = 'follow-links-weight';
       $row[] = drupal_render($form['follow_links'][$key]['weight']);
-  
+
       // Add the new row to our collection of rows, and give it the 'draggable' class.
       $rows[] = array(
         'data' => $row,
@@ -558,8 +570,9 @@ function follow_link_save($link) {
  *   An int containing the ID of a link.
  */
 function follow_link_delete($lid) {
-  $sql = 'DELETE FROM {follow_links} WHERE lid = %d';
-  db_query($sql, $lid);
+  db_delete('follow_links')
+    ->condition('lid', $lid)
+    ->execute();
 }
 
 
