? .project
? Copy of flag_content.module
? confirm_form
? flag_content_add_confirm.patch
? flag_content_remove_arg.patch
? flag_content_store_user.patch
Index: flag_content.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/flag_content/flag_content.install,v
retrieving revision 1.4
diff -u -p -r1.4 flag_content.install
--- flag_content.install	18 Feb 2007 04:10:17 -0000	1.4
+++ flag_content.install	23 Feb 2007 00:12:01 -0000
@@ -11,8 +11,9 @@ function flag_content_install() {
       $result = db_query("
         CREATE TABLE {flag_content}  (
           nid       INT NOT NULL,
+          uid       INT NOT NULL,
           timestamp INT,
-          PRIMARY KEY (nid)
+          PRIMARY KEY (nid, uid)
           ) /*!40100 DEFAULT CHARACTER SET utf8 */;
         ");
       break;
@@ -20,6 +21,7 @@ function flag_content_install() {
       $result = db_query("
         CREATE TABLE {flag_content} (
           nid       INTEGER PRIMARY KEY,
+          uid       INTEGER PRIMARY KEY,
           timestamp INTEGER
           )
         ");
@@ -31,3 +33,20 @@ function flag_content_uninstall() {
   db_query("DROP TABLE {flag_content}");
   db_query("DELETE FROM {variable} WHERE name like 'flag_content%%'");
 }
+
+function flag_content_update_1() {
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      $ret[] = update_sql('ALTER TABLE {flag_content} ADD uid INT NOT NULL AFTER nid');
+      $ret[] = update_sql('ALTER TABLE {flag_content} DROP PRIMARY KEY;');
+      $ret[] = update_sql('ALTER TABLE {flag_content} ADD PRIMARY KEY ( nid , uid )'); 
+      break;
+    case 'pgsql':
+      db_add_column($ret, 'flag_content', 'uid', 'INTEGER', array('not null' => TRUE));
+      $ret[] = update_sql('ALTER TABLE {flag_content} DROP CONSTRAINT {flag_content}_pkey');
+      $ret[] = update_sql('ALTER TABLE {flag_content} ADD PRIMARY KEY (nid, uid)');
+      break;
+  }
+  return $ret;
+}
Index: flag_content.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/flag_content/flag_content.module,v
retrieving revision 1.6.2.3
diff -u -p -r1.6.2.3 flag_content.module
--- flag_content.module	20 Feb 2007 00:44:16 -0000	1.6.2.3
+++ flag_content.module	23 Feb 2007 00:12:01 -0000
@@ -47,6 +47,13 @@ function flag_content_menu($may_cache) {
       'title'    => t('flagged items'),
       'access'   => user_access(FLAG_CONTENT_PERM_MANAGE),
     );
+    $items[] = array(
+      'path'     => 'flag_content/view/summary',
+      'callback' => 'flag_content_summary',
+      'title'    => t('Flagging summary'),
+      'type'     => MENU_CALLBACK,
+      'access'   => user_access(FLAG_CONTENT_PERM_MANAGE),
+    );
     
     $items[] = array(
       'path' => 'admin/settings/flag_content',
@@ -167,8 +174,10 @@ function flag_content_add($nid = 0) {
 function flag_content_add_submit($form_id, $form_values) {
   $nid = $form_values['nid'];
   if ($nid) {
+    global $user;
+
     // Insert the data into the table
-    db_query('INSERT INTO {flag_content} (nid, timestamp) VALUES (%d, %d)', $nid, time());
+    db_query('INSERT INTO {flag_content} (nid, uid, timestamp) VALUES (%d, %d, %d)', $nid, $user->uid, time());
     // Prepare the data
     $node = node_load($nid);
     // Email the admin
@@ -200,27 +209,60 @@ function flag_content_unflag_submit($for
 }
 
 function flag_content_view() {
-  print theme('page', theme('flag_content_view', _flag_content_get()));
+  return theme('flag_content_view', _flag_content_get());
+}
+
+/**
+ * Menu callback for 'flag_content/view/summary' that gives a summary for 
+ * flags for a passed node. 
+ */
+function flag_content_summary($nid = 0) {
+  // Not a valid node so go back to flag overview.
+  if (!$nid) {
+    drupal_goto('flag_content/view');
+  }
+
+  $rows = array();
+  $header = array(t('Title'), t('Author'), t('Flagged by'), t('Date'));
+
+  $node = node_load($nid);
+  $author = user_load(array('uid' => $node->uid));
+
+  $result = db_query('SELECT f.* FROM {flag_content} f WHERE nid = %d', $nid);
+  while ($flag = db_fetch_array($result)) {
+    $flagger = user_load(array('uid' => $flag['uid']));
+    $row = array(
+      l($node->title, "node/$nid"),
+      theme('username', $author),
+      theme('username', $flagger),
+      format_date($flag['timestamp']),
+    );
+    $rows[] = $row;      
+  } 
+  return theme('table', $header, $rows);
 }
 
 function theme_flag_content_view($list = array()) {
   $rows = array();
-  $header = array(t('Title'), t('Author'), t('Date'), t('Operations'));
+  $header = array(t('Title'), t('Author'), t('Number of flags'), t('Date'), t('Operations'));
   if (count($list)) {
     foreach($list as $nid => $data) {
       $title = l($data['title'], "node/$nid");
       $author = $data['author'];
       $user = theme('username', $data['author']);
       $timestamp = format_date($data['timestamp'], 'custom', 'Y-m-d H:i');
-      $ops = l(t('edit'),   "node/$nid/edit");
-      $ops .= ' ' . l(t('unflag'), "flag_content/unflag/$nid");
-      $ops .= ' ' . l(t('delete'), "node/$nid/delete");
+      $ops[] = l(t('flag summary'), "flag_content/view/summary/$nid");
+      $ops[] = l(t('edit'),   "node/$nid/edit");
+      $ops[] = l(t('unflag'), "flag_content/unflag/$nid");
+      $ops[] = l(t('delete'), "node/$nid/delete");
 
       $rows[] = array('data' => array_merge(
         array($title),
         array($user),
+        array($data['flag_count']),
         array($timestamp),
-        array($ops)));
+        array(implode(' | ', $ops))),
+      );
     }
   }
   else {
@@ -244,8 +286,8 @@ function _flag_content_unflag($nid) {
 
 function _flag_content_get() {
   $rows = array();
-  $sql = "SELECT n.nid, n.title, n.uid, f.timestamp
-    FROM {node} n INNER JOIN {flag_content} f USING(nid)
+  $sql = "SELECT n.nid, n.title, n.uid, COUNT(f.uid) AS flag_count, f.timestamp
+    FROM {node} n INNER JOIN {flag_content} f USING(nid) GROUP BY uid
     ORDER by f.timestamp ASC";
   $result = db_query($sql);
   while ($data = db_fetch_object($result)) {
@@ -253,6 +295,7 @@ function _flag_content_get() {
       'title' => $data->title,
       'author' => user_load(array('uid' => $data->uid)),
       'timestamp' => $data->timestamp,
+      'flag_count' => $data->flag_count,
       );
   }
   return $rows;
