Index: flag_content.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/flag_content/flag_content.module,v
retrieving revision 1.14
diff -u -r1.14 flag_content.module
--- flag_content.module	2 Feb 2008 18:11:53 -0000	1.14
+++ flag_content.module	2 Feb 2008 19:04:11 -0000
@@ -1,6 +1,4 @@
 <?php
-// $Id: flag_content.module,v 1.14 2008/02/02 18:11:53 kbahey Exp $
-
 // Copyright 2006-2007 Khalid Baheyeldin http://2bits.com
 
 define('FLAG_CONTENT_NODE_TYPE',    'flag_content_node_type_');
@@ -25,42 +23,36 @@
   return array(FLAG_CONTENT_PERM_ADD, FLAG_CONTENT_PERM_MANAGE, FLAG_CONTENT_PERM_ADMIN);
 }
 
-function flag_content_menu($may_cache) {
+function flag_content_menu() {
   $items = array();
-  if ($may_cache) {
-    $items[] = array(
-      'path'               => 'admin/settings/flag_content',
-      'title'              => t('Flag content'),
-      'description'        => t('Settings for the flag content module.'),
-      'callback'           => 'drupal_get_form',
-      'callback arguments' => array('flag_content_admin_settings'),
-      'access'             => user_access(FLAG_CONTENT_PERM_ADMIN),
+    $items['admin/settings/flag_content'] = array(
+      'title'              => 'Flag content',
+      'description'        => 'Settings for the flag content module.',
+      'page callback'      => 'drupal_get_form',
+      'page arguments'     => array('flag_content_admin_settings'),
+      'access arguments'   => array(FLAG_CONTENT_PERM_MANAGE),
     );
 
-    $items[] = array(
-      'path'               => 'flag_content/add',
-      'callback'           => 'drupal_get_form',
-      'callback arguments' => array('flag_content_add'),
+    $items['flag_content/add'] = array(
+      'page callback'      => 'drupal_get_form',
+      'page arguments'     => array('flag_content_add', 2, 3),
       'type'               => MENU_CALLBACK,
-      'access'             => user_access(FLAG_CONTENT_PERM_ADD),
+      'access arguments'   => array(FLAG_CONTENT_PERM_ADD),
     );
 
-    $items[] = array(
-      'path'               => 'flag_content/unflag',
-      'callback'           => 'drupal_get_form',
-      'callback arguments' => array('flag_content_unflag'),
+    $items['flag_content/unflag'] = array(
+      'page callback'      => 'drupal_get_form',
+      'page arguments'     => array('flag_content_unflag'),
       'type'               => MENU_CALLBACK,
-      'access'             => user_access(FLAG_CONTENT_PERM_MANAGE),
+      'access arguments'   => array(FLAG_CONTENT_PERM_MANAGE),
     );
 
-    $items[] = array(
-      'path'               => 'admin/content/flag_content',
-      'callback'           => 'flag_content_view',
-      'title'              => t('Flagged items'),
-      'description'        => t('View, edit, delete flagged nodes, comments, or users.'),
-      'access'             => user_access(FLAG_CONTENT_PERM_MANAGE),
+    $items['admin/content/flag_content'] = array(
+      'page callback'      => 'flag_content_view',
+      'title'              => 'Flagged items',
+      'description'        => 'View, edit, delete flagged nodes, comments, or users.',
+      'access arguments'   => array(FLAG_CONTENT_PERM_MANAGE),
     );
-  }
   return $items;
 }
 
@@ -116,9 +108,8 @@
 /**
  *  Implementation of hook_user().
  */
-function flag_content_user($op, &$edit, &$account, $category = NULL) {
+function flag_content_user($op, &$edit, &$account) {
   global $user;
-
   switch($op) {
     case 'view':
       if ($user->uid == $account->uid) {
@@ -126,16 +117,22 @@
         return array();
       }
 
-      $items = array();
       $links = flag_content_link(FLAG_CONTENT_TYPE_USER, $account);
+      
       foreach($links as $key => $value) {
-        $items[] = array(
-          'class' => $key,
-          'value' => l($value['title'], $value['href'], $value['attributes']),
-        );
+        $class = $key;
+        $title = $value['title'];
+        $href = $value['href'];
+        $attributes = $value['attributes'];
       }
-      return array(t('Flag user') => $items);
-
+      $account->content['summary']['flag_content'] = array(
+        '#type' => 'user_profile_item',
+        '#title' => t('Flag user'),          
+        '#attributes' => array('class' => $class),
+        '#value' => l($title, $href),
+      );
+      
+    break;
     case 'delete':
       db_query("DELETE FROM {flag_content} WHERE eid = %d AND type = '%s'", $account->uid, FLAG_CONTENT_TYPE_USER);
       break;
@@ -225,7 +222,7 @@
   return $links;
 }
 
-function flag_content_add($eid = 0, $type = FLAG_CONTENT_TYPE_NODE) {
+function flag_content_add(&$form_state, $eid = 0, $type = FLAG_CONTENT_TYPE_NODE) {
   switch ($type) {
     case FLAG_CONTENT_TYPE_NODE:
       $node = node_load($eid);
@@ -260,16 +257,16 @@
   return confirm_form(
     $form,
     t('Are you sure you want to flag the @type @title', array('@type' => $type_label, '@title' => $title)),
-    $_GET['destination'] ? $_GET['destination'] : $path,
+    !empty($_GET['destination']) ? $_GET['destination'] : $path,
     t(''),
     t('Flag'),
     t('Cancel'));
 }
 
-function flag_content_add_submit($form_id, $form_values) {
+function flag_content_add_submit($form, &$form_state) {
   global $user;
-  $eid = $form_values['eid'];
-  $type = $form_values['type'];
+  $eid = $form_state['values']['eid'];
+  $type = $form_state['values']['type'];
   if ($eid && $type) {
     // Insert the data into the table
     db_query("INSERT INTO {flag_content} (fid, eid, uid, type, timestamp) VALUES (0, %d, %d, '%s', %d)",
@@ -305,10 +302,10 @@
     drupal_set_message(t('The @type was flagged for the administrator', array('@type' => $type == FLAG_CONTENT_TYPE_NODE ? t('item') : $type)));
   }
 
-  return $_GET['destination'] ? $_GET['destination'] : $path;
+  $form_state['redirect'] = !empty($_GET['destination']) ? $_GET['destination'] : $path;
 }
 
-function flag_content_unflag($eid = 0, $type = FLAG_CONTENT_TYPE_NODE) {
+function flag_content_unflag(&$form_state, $eid = 0, $type = FLAG_CONTENT_TYPE_NODE) {
   switch ($type) {
     case FLAG_CONTENT_TYPE_NODE:
       $node = node_load($eid);
@@ -338,20 +335,20 @@
   return confirm_form(
     $form,
     t('Are you sure you want to unflag the @type @title', array('@type' => $type_label, '@title' => $title)),
-    $_GET['destination'] ? $_GET['destination'] : $type. '/'. $eid,
+    !empty($_GET['destination']) ? $_GET['destination'] : $type. '/'. $eid,
     t(''),
     t('Unflag'),
     t('Cancel'));
 }
 
-function flag_content_unflag_submit($form_id, $form_values) {
-  $eid = $form_values['eid'];
-  $type = $form_values['type'];
+function flag_content_unflag_submit($form, &$form_state) {
+  $eid = $form_state['values']['eid'];
+  $type = $form_state['values']['type'];
   if ($eid && $type) {
     _flag_content_unflag($eid, $type);
     drupal_set_message(t('The @type was unflagged.', array('@type' => $type == FLAG_CONTENT_TYPE_NODE ? t('item') : $type)));
   }
-  return 'admin/content/flag_content';
+  $form_state['redirect'] = 'admin/content/flag_content';
 }
 
 function flag_content_view() {
@@ -382,7 +379,7 @@
         case FLAG_CONTENT_TYPE_COMMENT:
           $comment = db_fetch_object(db_query('SELECT * FROM {comments} WHERE cid = %d', $entry->eid));
           $subject = $comment->subject ? $comment->subject : 'comment';
-          $item = l($subject, url('node/' . $comment->nid, NULL, NULL, 1) . "#comment-" . $comment->cid);
+          $item = l($subject, url('node/' . $comment->nid, array('absolute' => TRUE)) . "#comment-" . $comment->cid);
           $edit = "comment/edit/$comment->cid";
           $delete = "comment/delete/$comment->cid";
           $type = $entry->type;
@@ -446,7 +443,7 @@
     case FLAG_CONTENT_TYPE_COMMENT:
       $title = $entry->subject;
       $eid = $entry->cid;
-      $path = url('node/' . $entry->nid, NULL, NULL, 0) . "#comment-" . $entry->cid;
+      $path = url('node/' . $entry->nid, array('absolute' => TRUE)) . "#comment-" . $entry->cid;
       break;
   }
 
@@ -487,3 +484,14 @@
     'body'    => $body,
   );
 }
+
+function flag_content_theme() {
+  return array(
+    'flag_content_view' => array(
+      'arguments' => array('content'),
+    ),
+    'flag_content_mail' => array(
+      'arguments' => array('content'),
+    ),
+  );
+}
\ No newline at end of file
