Project

General

Profile

« Previous | Next » 

Revision 863

Added by aldus almost 16 years ago

Modify to get informations where the modul is in use when
a user try to uninstall it.

View differences:

uninstall.php
50 50
	$admin->print_error($MESSAGE['MODULES']['NOT_INSTALLED']);
51 51
}
52 52

  
53
// Check if the module is in use
54
$query_modules = $database->query("SELECT section_id FROM ".TABLE_PREFIX."sections WHERE module = '".$admin->add_slashes($_POST['file'])."' LIMIT 1");
55
if($query_modules->numRows() > 0) {
56
	$admin->print_error($MESSAGE['GENERIC']['CANNOT_UNINSTALL_IN_USE']);
53
/**
54
*	Check if the module is in use
55
*
56
*	@version	0.1.0
57
*	@build		1
58
*	@date		2008-10-23
59
*	@author		aldus
60
*	@package	Websitebaker - Admin - modules
61
*	@state		@dev
62
*
63
*/
64

  
65
if (!function_exists("replace_all")) {
66
	function replace_all ($aStr = "", &$aArray ) {
67
		foreach($aArray as $k=>$v) $aStr = str_replace("{{".$k."}}", $v, $aStr);
68
		return $aStr;
69
	}
57 70
}
58 71

  
72
$info = $database->query("SELECT section_id, page_id FROM ".TABLE_PREFIX."sections WHERE module='".$_POST['file']."'" );
73

  
74
if ( $info->numRows() > 0) {
75
	
76
	/**
77
	*	Modul is in use, so we have to warn the user
78
	*/
79
	
80
	$add = $info->numRows() == 1 ? "this page" : "these pages";
81
	$msg_template_str  = "<br /><br />Modul <b>{{modul_name}}</b> could not be uninstalled because it is still in use on ";
82
	$msg_template_str .= $add.":<br /><i>click for editing.</i><br /><br />";
83

  
84
	/**
85
	*	The template-string for displaying the Page-Titles ... in this case as a link
86
	*/
87
	$page_template_str = "- <b><a href='../pages/sections.php?page_id={{id}}'>{{title}}</a></b><br />";
88
	
89
	$values = array ('modul_name' => $file);
90
	$msg = replace_all ( $msg_template_str,  $values );
91
		
92
	$page_names = "";
93
	
94
	while ($data = $info->fetchRow(DB_FETCHMODE_ASSOC) ) {
95
	
96
		$temp = $database->query("SELECT page_title from ".TABLE_PREFIX."pages where page_id=".$data['page_id']);
97
		$temp_title = $temp->fetchRow( DB_FETCHMODE_ASSOC );
98
		
99
		$page_info = array(
100
			'id'	=> $data['page_id'], 
101
			'title' => $temp_title['page_title']
102
		);
103
			
104
		$page_names .= replace_all ( $page_template_str, $page_info );
105
	}
106
	
107
	/**
108
	*	Printing out the error-message and die().
109
	*/
110
	$admin->print_error(str_replace ("Datei", "Modul", $MESSAGE['GENERIC']['CANNOT_UNINSTALL_IN_USE']).$msg.$page_names);
111
}
112

  
59 113
// Check if we have permissions on the directory
60 114
if(!is_writable(WB_PATH.'/modules/'.$file)) {
61 115
	$admin->print_error($MESSAGE['GENERIC']['CANNOT_UNINSTALL']);

Also available in: Unified diff