<?php
/*======================================================================================
Module: Articles
======================================================================================*/

// Check authorisation
if (!isset($gCms)) exit;

// Get db handle
$dict = NewDataDictionary($db);
$taboptarray = array('mysql' => 'TYPE=MyISAM');

// drop tables
$sqlarray = $dict->DropTableSQL(cms_db_prefix() . 'module_articles_articles');
$dict->ExecuteSQLArray($sqlarray);
$sqlarray = $dict->DropTableSQL(cms_db_prefix() . 'module_articles_category');
$dict->ExecuteSQLArray($sqlarray);
$sqlarray = $dict->DropTableSQL(cms_db_prefix() . 'module_articles_category_articles');
$dict->ExecuteSQLArray($sqlarray);
$sqlarray = $dict->DropTableSQL(cms_db_prefix() . 'module_articles_orders');
$dict->ExecuteSQLArray($sqlarray);

// Delete module templates
$this->DeleteTemplate();

// Delete module preferences
$this->RemovePreference();

// remove permissions
$this->RemovePermission('Articles: modify articles');
$this->RemovePermission('Articles: modify categories');
$this->RemovePermission('Articles: modify settings');
$this->RemovePermission('Articles: show orders');

// delete image folder
$deldir = cms_join_path($config['image_uploads_path'],'Articles','articles');
if (is_dir($deldir)) if (!rmdir($deldir)) { echo "Error removing dir $deldir"; }
$deldir = cms_join_path($config['image_uploads_path'],'Articles','categories');
if (is_dir($deldir)) if (!rmdir($deldir)) { echo "Error removing dir $deldir"; }
$deldir = cms_join_path($config['image_uploads_path'],'Articles');
if (is_dir($deldir)) if (!rmdir($deldir)) { echo "Error removing dir $deldir"; }

// put mention into the admin log
$this->Audit( 0, $this->Lang('friendlyname'), $this->Lang('postuninstall'));

// EOF