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); } }
// Remove private data Doctrine_Query::create()->delete()->from('UserPrivateData')->addWhere("id = '{$userid_to_wipe}'")->execute(); $conn->commit(); } catch (Exception $e) { $conn->rollback(); echo "A problem occured during merging\n"; throw $e; } // Clear cache - We cannot use function from c2cActions since it is protected $cache_dir = sfConfig::get('sf_root_cache_dir') . '/frontend/*/template/*/all'; $cache_dir .= sfConfig::get('sf_no_script_name') ? '/' : '/*/'; //c2cActions::clearCache('users', $userid_to_wipe, false); $toRemove[] = "users/*/id/{$userid_to_wipe}/*"; //c2cActions::clearCache('users', $userid_to_remain, false); $toRemove[] = "users/*/id/{$userid_to_remain}/*"; // find all docs associated to user_id_to_remain and clear the cache $associated_docs = Association::findAllAssociatedDocs($userid_to_remain, array('id', 'module')); foreach ($associated_docs as $doc) { //c2cActions::clearCache($doc['module'], $doc['id'], false, 'view'); $toRemove[] = "{$doc['module']}/view/id/{$doc['id']}/*"; } // find all geo associated docs $associated_docs = GeoAssociation::findAllAssociatedDocs($userid_to_remain, array('id', 'module')); foreach ($associated_docs as $doc) { //c2cActions::clearCache($doc['module'], $doc['id'], false, 'view'); $toRemove[] = "{$doc['module']}/view/id/{$doc['id']}/*"; } foreach ($toRemove as $item) { sfToolkit::clearGlob($cache_dir . $item); } echo "Users successfully merged\n";