function deletePlugin($dir) { $mydir = opendir($dir); while (false !== ($file = readdir($mydir))) { if ($file != "." && $file != "..") { chmod($dir . $file, 0777); if (is_dir($dir . $file)) { chdir('.'); deletePlugin($dir . $file . '/'); if (is_dir($dir . $file)) { rmdir($dir . $file) or die("<span style='color: #fff'>" . $t['couldnt delete dir'] . ": {$dir}{$file}</span><br />"); } } else { unlink($dir . $file) or die("<span style='color: #fff''>" . $t['couldnt delete file'] . ": {$dir}{$file}</span><br />"); } } } closedir($mydir); rmdir($dir); }
/** * delete a cluster * @param integer ID of cluster, that is to be deleted. */ function deleteCluster($clid) { global $db; $delHandler = new ActionHandler("del"); $sql = "SELECT CLCID, CLTI_ID, FKID FROM cluster_content WHERE CLID = {$clid}"; $query = new query($db, $sql); while ($query->getrow()) { $clcid = $query->field("CLCID"); $clti = $query->field("CLTI_ID"); $fkid = $query->field("FKID"); if ($fkid == 0 && $clti != 0) { // delete no other clusters as this is done automatically by the callers anyway. $sql = "SELECT FKID FROM cluster_template_items WHERE CLTI_ID = {$clti}"; $cquery = new query($db, $sql); $cquery->getrow(); $module = $cquery->field("FKID"); $cquery->free(); deletePlugin($clcid, $module); } } $sql = "DELETE FROM cluster_content WHERE CLID = {$clid}"; $query = new query($db, $sql); }
global $configuration; $generate = new sfSympalPluginGenerateTask($configuration->getEventDispatcher(), new sfFormatter()); $generate->run(array($name), array('--re-generate', '--no-confirmation', '--content-type=' . $contentType)); $t->is(file_exists(sfConfig::get('sf_plugins_dir') . '/' . sfSympalPluginToolkit::getLongPluginName($name)), true, 'Test that the plugin was generated'); } function downloadPlugin($name, $t) { $manager = sfSympalPluginManager::getActionInstance($name, 'uninstall'); $manager->uninstall(true); $manager = sfSympalPluginManager::getActionInstance($name, 'download'); $manager->download(); $t->is(file_exists(sfConfig::get('sf_plugins_dir') . '/' . $name), true, 'Test that the plugin exists and was downloaded'); } function deletePlugin($name, $t) { $t->info('Deleting plugin ' . $name); $manager = sfSympalPluginManager::getActionInstance($name, 'delete'); $manager->delete(); $t->is(file_exists(sfConfig::get('sf_plugins_dir') . '/' . $name), false, 'The plugin was deleted entirely'); $t->is(file_exists(sfConfig::get('sf_lib_dir') . '/model/doctrine/' . $name), false, 'The model files were deleted'); $t->is(file_exists(sfConfig::get('sf_lib_dir') . '/form/doctrine/' . $name), false, 'The form files were deleted'); $t->is(file_exists(sfConfig::get('sf_lib_dir') . '/filter/doctrine/' . $name), false, 'The filter files were deleted'); } $t->info('1 - Download a plugin and see that it exists'); downloadPlugin('sfSympalObjectReplacerPlugin', $t); $t->info('2 - Generate a content type plugin, see that it exists'); generatePlugin('Event', 'Event', $t); $t->info('3 - Delete both plugins'); deletePlugin('sfSympalObjectReplacerPlugin', $t); deletePlugin('sfSympalEventPlugin', $t);
/** * delete all (also live) instances of a variation. * @param integer ID of the Variation */ function deleteVariation($variation) { global $db; $delHandler = new ActionHandler("del"); $delHandler->addDBAction("DELETE FROM sitepage_names WHERE VARIATION_ID = $variation"); $delHandler->addDBAction("DELETE FROM sitepage_variations WHERE VARIATION_ID = $variation"); // delete clusters $sql = "SELECT CLID FROM cluster_variations WHERE VARIATION_ID = $variation"; $query = new query($db, $sql); while ($query->getrow()) { deleteCluster ($query->field("CLID")); } $delHandler->addDBAction("DELETE FROM cluster_variations WHERE VARIATION_ID = $variation"); // delete content $sql = "SELECT v.FK_ID, c.MODULE_ID FROM content_variations v, content c WHERE c.CID = v.CID AND v.VARIATION_ID = $variation"; $query = new query($db, $sql); while ($query->getrow()) { deletePlugin($query->field("FK_ID"), $query->field("MODULE_ID")); } $delHandler->addDBAction("DELETE FROM content_variations WHERE VARIATION_ID = $variation"); $delHandler->addDBAction("DELETE FROM variations WHERE VARIATION_ID = $variation"); $delHandler->process("del"); }