public function executeDelete() { $referer = $this->getRequest()->getReferer(); if ($id = $this->getRequestParameter('id')) { $document = Document::find($this->model_class, $id, array('module')); if (!$document) { $this->setErrorAndRedirect('Document does not exist', $referer); } $module = $document->get('module'); $this->deleteLinkedFile($id); $nb_dv_deleted = Document::doDelete($id); c2cTools::log("executeDelete: deleted document {$id} and its {$nb_dv_deleted} versions (all langs taken into account)"); if ($nb_dv_deleted) { // cache clearing for deleted doc in every lang, without whatsnew: $this->clearCache($module, $id, false); // find all associated docs $associated_docs = Association::findAllAssociatedDocs($id, array('id', 'module')); foreach ($associated_docs as $doc) { // clear their view cache $this->clearCache($doc['module'], $doc['id'], false, 'view'); } // remove all general associations concerned by this document $deleted = Association::deleteAll($id); c2cTools::log("executeDelete: deleted {$deleted} general associations concerning this doc"); // find all geo associated docs $associated_docs = GeoAssociation::findAllAssociatedDocs($id, array('id', 'module')); foreach ($associated_docs as $doc) { // clear their view cache $this->clearCache($doc['module'], $doc['id'], false, 'view'); } // remove all geo associations concerned by this document $deleted += GeoAssociation::deleteAll($id); c2cTools::log("executeDelete: deleted {$deleted} general associations concerning this doc"); // flash info: $this->setNoticeAndRedirect('Document deleted', "@default_index?module={$module}"); } else { $this->setErrorAndRedirect('Document could not be deleted', $referer); } } else { $this->setErrorAndRedirect('Could not understand your request', $referer); } }