diff -urp filedepot/ajaxserver.php filedepot-tagcloud/ajaxserver.php
--- filedepot/ajaxserver.php	2010-06-20 02:05:19.000000000 -0400
+++ filedepot-tagcloud/ajaxserver.php	2010-09-13 21:10:14.000000000 -0400
@@ -298,6 +298,9 @@ function filedepot_dispatcher($action) {
         $cid = db_result(db_query("SELECT catid FROM {filedepot_access} WHERE accid=%d", $id));
         if ($filedepot->checkPermission($cid, 'admin')) {
           db_query("DELETE FROM {filedepot_access} WHERE accid=%d", $id);
+          // For this folder - I need to update the access metrics now that a permission has been removed
+          $nexcloud->update_accessmetrics($cid);
+          db_query("DELETE FROM {filedepot_access} WHERE accid=%d", $id);
           db_query("UPDATE {filedepot_usersettings} set allowable_view_folders = ''");
           if ($filedepot->ogenabled) {
             $data['html'] = theme('filedepot_folderperms_ogenabled', $cid);
@@ -328,6 +331,8 @@ function filedepot_dispatcher($action) {
       $_POST['selgroups'],           // Array of group members
       $_POST['selroles'])            // Array of roles
       ) {
+
+        $nexcloud->update_accessmetrics($cid);
         if ($filedepot->ogenabled) {
           $data['html'] = theme('filedepot_folderperms_ogenabled', $cid);
         } else {
@@ -384,18 +389,26 @@ function filedepot_dispatcher($action) {
           $upload_direct = $filedepot->checkPermission($cid, 'upload_dir');
           $upload_moderated = $filedepot->checkPermission($cid, 'upload');
           $upload_new_versions = $filedepot->checkPermission($cid, 'upload_ver');
+          if (!$upload_direct AND $upload_moderated) {  // Admin's have all perms so test for users with upload moderated approval only
+            $file->moderated = TRUE;
+          }
+          else {
+            $file->moderated = FALSE;
+          }
 
           // Is this a new file or new version to an existing file
           if (intval($_POST['fid']) > 0 AND $upload_new_versions)  {    // Uploading a new version for an existing file record
             $fid = intval($_POST['fid']);
             $cid = db_result(db_query("SELECT cid FROM {filedepot_files} WHERE fid=%d", $fid));
-            $file->moderated = FALSE;
             $file->folder = $cid;
             $file->fid = $fid;
             $file->vernote = $vernote;
             $file->tags = $tags;
             $validators = array();
             $file->nid = db_result(db_query("SELECT nid FROM {filedepot_categories} WHERE cid=%d", $cid));
+            /* @TODO: saveVersion needs to be updated to handle moderated uploads.
+             * Presently a user with upload (moderated) and upload_version can upload new versions directly
+             */
             if ($filedepot->saveVersion($file, $validators)) {
               $data['message'] = '';
               $data['fid'] = $fid;
@@ -411,12 +424,6 @@ function filedepot_dispatcher($action) {
 
           }
           elseif ($upload_direct OR $upload_moderated) {
-            if (!$upload_direct AND $upload_moderated) {  // Admin's have all perms so test for users with upload moderated approval only
-              $file->moderated = TRUE;
-            }
-            else {
-              $file->moderated = FALSE;
-            }
             $file->title = $_POST['displayname'];
             $file->folder = intval($_POST['category']);
             $file->description = $_POST['description'];
diff -urp filedepot/filedepot.install filedepot-tagcloud/filedepot.install
--- filedepot/filedepot.install	2010-08-07 15:22:48.000000000 -0400
+++ filedepot-tagcloud/filedepot.install	2010-09-13 21:48:36.000000000 -0400
@@ -966,6 +966,11 @@ $schema['nextag_items'] = array(
 $schema['nextag_metrics'] = array(
   'description' => t('TODO: please describe this table!'),
   'fields' => array(
+    'id' => array(
+      'description' => t('TODO: please describe this field!'),
+      'type' => 'serial',
+      'not null' => TRUE,
+    ),
     'tagid' => array(
       'description' => t('TODO: please describe this field!'),
       'type' => 'int',
@@ -1002,6 +1007,7 @@ $schema['nextag_metrics'] = array(
       'default' => 0,
     ),
   ),
+  'primary key' => array('id'),
   'indexes' => array(
     'tagid' => array('tagid'),
     'type' => array('type'),
@@ -1055,3 +1061,19 @@ function filedepot_update_6002() {
 }
 
 
+/**
+ * Implementation of hook_update_N().
+ * POST Version 1.0.0 - fix for better managing tagwords associated with folder permission changes
+ * See Issue# 887604
+ */
+function filedepot_update_6003() {
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      db_query("ALTER TABLE {nextag_metrics} ADD `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST");
+      break;
+    case 'pgsql':
+      db_change_column($ret, 'nextag_metrics', 'id', 'id', 'int', array('not null' => FALSE, 'serial' => TRUE));
+      break;
+    }
+}
diff -urp filedepot/nexcloud.class.php filedepot-tagcloud/nexcloud.class.php
--- filedepot/nexcloud.class.php	2010-06-20 02:36:57.000000000 -0400
+++ filedepot-tagcloud/nexcloud.class.php	2010-09-13 21:10:15.000000000 -0400
@@ -228,6 +228,88 @@
     }
 
 
+    /*
+    * Used when item permissions are changed and we need to possibly remove or add some tag_metrics records
+    * Each file identified by tagid of type 'filedepot' will have a record per permission assigned
+    * So if the folder has 10 files with tags, 2 role permissions and a group permission - there will be 3 record per file
+    * @param string $itemid  - file id, used to get the access permissions
+    */
+    function update_accessmetrics($itemid, $tagids='') {
+
+      if (empty($tagids)) { // Retrieve the tags field and convert into an array
+        $tags = db_result(db_query("SELECT tags FROM {nextag_items} WHERE type='%s' AND itemid=%d", $this->_type, $itemid));
+        if (!empty($tags)) {
+          $tagids = explode(',',$tags);
+        }
+        else {
+          $tagids = array();
+        }
+      }
+
+      // Test that we now have a valid array of tag id's
+      if (is_array($tagids) AND count($tagids) > 0) {
+        // Test that a valid item record exist
+        if (db_result(db_query("SELECT count(itemid) FROM {nextag_items} WHERE type='%s' AND itemid=%d", $this->_type, $itemid)) > 0) {
+          // Get item permissions to determine what rights to use for tag metrics record
+          $perms = $this->get_itemperms($itemid);
+          // For each role or group with view access to this item - create or update the access metric record count.
+          $haveGroupsToUpdate = count($perms['groups']) > 0;
+          $haveRolesToUpdate = count($perms['roles']) > 0;
+
+          // For each tag word - we need to update (add new or remove any un-used tag metric associated with this permission and tagword
+          $metricRecords = array(); // Will contain the processed metric records
+          foreach ($tagids as $id) {
+            if (!empty($id)) {
+              if($haveGroupsToUpdate OR $haveRolesToUpdate) {
+
+                // An array to handle the logic of whether to process groups, roles, or both
+                // Use the key to track the field to update and the value to track the values
+                $permAccessMetric = array();
+                if ($haveGroupsToUpdate) {
+                    $permAccessMetric['groupid'] = $perms['groups'];
+                }
+                if ($haveRolesToUpdate) {
+                    $permAccessMetric['roleid'] = $perms['roles'];
+                }
+                foreach ($permAccessMetric as $permKey => $permValue) {
+                  foreach ($permValue as $permid) {
+                    if ($permid > 0) {
+                      $result = db_query("SELECT id FROM {nextag_metrics} WHERE tagid = %d AND type = '%s' AND %s = %d", $id, $this->_type, $permKey, $permid);
+                      $numrecs = 0;
+                      if ($result) {
+                        while ($rec = db_fetch_object($result)) {
+                          $numrecs++;
+                          if (!in_array($rec->id,$metricRecords)) $metricRecords[] = $rec->id;
+                        }
+                      }
+                      if ($numrecs == 0) {
+                        $sql  = "INSERT INTO {nextag_metrics} (tagid,type," . $permKey . ",metric,last_updated) "
+                                . "VALUES (%d,'%s',%d,%d,%d)";
+                        db_query($sql, $id, $this->_type, $permid, 1, time());
+                        $metricRecords[] = db_last_insert_id('nextag_metrics','id');
+                      }
+                    }
+                  }
+                }
+              }
+            }
+
+            /* Now we should delete any metric records that are not in the processed $metricRecords array
+             * They would be records for access permissions that were removed
+             */
+            if (count($metricRecords) > 0) {
+              $recids = implode(',',$metricRecords);
+              db_query("DELETE FROM {nextag_metrics} WHERE tagid = %d and id NOT IN (%s)",$id,$recids);
+            } else {
+              db_query("DELETE FROM {nextag_metrics} WHERE tagid = %d ",$id);
+            }
+
+          }
+
+        }
+      }
+    }
+
 
     /* Update tag metrics for an existing item.
     * Should work for all modules - adding tags or updating tags
@@ -426,4 +508,15 @@
       $this->_type = 'filedepot';
     }
 
+    /* For each file in this folder with tagwords - update the metrics per access permission */
+    function update_accessmetrics($cid) {
+      $sql  = "SELECT a.itemid FROM {nextag_items} a ";
+      $sql .= "LEFT JOIN {filedepot_files} b on b.fid = a.itemid ";
+      $sql .= "WHERE b.cid = %d";
+      $result = db_query($sql,$cid);
+      while ($A = db_fetch_array($result)) {
+        parent::update_accessmetrics($A['itemid']);
+      }
+    }
+
   }
