function _uploads_AdminDoDeleteCategory(&$module, $category_id) { // get the category details $category = $module->_getUploadCategoryDetails($category_id); if (!$category) { return $module->Lang('error_categorynotfound'); } // get the files from the category $query = 'SELECT upload_id FROM ' . cms_db_prefix() . 'module_uploads WHERE upload_category_id = ?'; $db =& $module->GetDb(); $tmp = $db->GetOne($query, array($category_id)); if ($tmp) { return $module->Lang('error_categorynotempty'); } $dir = $module->_categoryPath($category['upload_category_path']); cge_dir::recursive_rmdir($dir); if (file_exists($dir)) { return $module->Lang('error_delete', $dir); } // delete the category from the db $db =& $module->GetDb(); $query = "DELETE FROM " . cms_db_prefix() . "module_uploads_categories WHERE upload_category_id = ?"; $dbresult = $db->Execute($query, array($category_id)); // send an event $parms[] = array(); $parms['name'] = $category['upload_category_name']; $parms['path'] = $category['upload_category_path']; $module->SendEvent('OnDeleteCategory', $parms); // and we're done return FALSE; }
$n_removed = $this->clear_cached_files(); $this->SetMessage($this->Lang('msg_cachecleaned', $n_removed)); audit('', $this->GetName(), $n_removed . ' files cleaned from cache directory'); } else { if (isset($params['clear_all'])) { // just nuke the cache directory completely. $cache_path = $this->GetPreference('cache_path', cms_join_path('uploads', '_' . $this->GetName())); $dir = $cache_path; if (!startswith($dir, '/')) { $dir = $config['root_path'] . '/' . $cache_path; } $p1 = realpath($dir); $p2 = realpath($config['root_path']); if (!startswith($p1, $p2) || $p1 == $p2) { throw new Exception($this->Lang('error_cachepath_invalid')); } cge_dir::recursive_rmdir($dir); mkdir($dir); @touch($dir . '/index.html'); $this->SetMessage($this->Lang('msg_cacheremoved')); audit('', $this->GetName(), 'All cached files removed'); } } } } catch (Exception $e) { $this->SetError($e->getMessage()); } $this->RedirectToTab($id); # # EOF #