You are here

function filedepot_entity_delete in filedepot 7

Implementation of hook_entity_insert().

If OG Mode enabled, delete any folder access perms and tag access records

File

./filedepot.module, line 1390
filedepot.module Filedepot: File Management Module developed by Nextide www.nextide.ca Full featured document managment module with a desktop application feel. Integrated Organic Group, Role and User permissions to secure folders, automated…

Code

function filedepot_entity_delete($entity, $type) {
  if ($type == 'group' and $entity->gid > 0) {
    $result = db_query("SELECT accid, catid FROM {filedepot_access} WHERE permtype = 'group' AND permid = :id", array(
      ':id' => $entity->gid,
    ));
    if ($result) {
      module_load_include('php', 'filedepot', 'nexcloud.class');
      $nexcloud = new filedepotTagCloud();
      foreach ($result as $rec) {
        db_query("DELETE FROM {filedepot_access} WHERE accid=:recid", array(
          ':recid' => $rec->accid,
        ));
        db_query("UPDATE {filedepot_usersettings} set allowable_view_folders = ''");

        // For this folder - update the access metrics now that a permission has been removed
        $nexcloud
          ->update_accessmetrics($rec->catid);
      }
    }
  }
}