|
51 | 51 |
|
52 | 52 | class page_action extends tform_actions { |
53 | 53 |
|
| 54 | + // db_table => info_field for onDelete - empty = show only the amount |
| 55 | + private $tables = array( |
| 56 | + 'cron' => '', |
| 57 | + 'client' => 'contact_name', |
| 58 | + 'dns_rr' => '', |
| 59 | + 'dns_soa' => 'origin', |
| 60 | + 'dns_slave' => 'origin', |
| 61 | + 'domain' => 'domain', |
| 62 | + 'ftp_user' => 'username', |
| 63 | + 'mail_access' => 'source', |
| 64 | + 'mail_content_filter' => '', |
| 65 | + 'mail_domain' => 'domain', |
| 66 | + 'mail_forwarding' => '', |
| 67 | + 'mail_get' => '', |
| 68 | + 'mail_mailinglist' => 'listname', |
| 69 | + 'mail_user' => 'email', |
| 70 | + 'mail_user_filter' => '', |
| 71 | + 'shell_user' => 'username', |
| 72 | + 'spamfilter_users' => '', 'spamfilter_wblist' => '', |
| 73 | + 'support_message' => '', |
| 74 | + 'web_domain' => 'domain', |
| 75 | + 'web_folder' => 'path', |
| 76 | + 'web_folder_user' => 'username', |
| 77 | + 'web_database_user' => 'database_user', |
| 78 | + ); |
| 79 | + |
54 | 80 | function onDelete() { |
55 | 81 | global $app, $conf, $list_def_file, $tform_def_file; |
56 | 82 |
|
@@ -80,27 +106,29 @@ function onDelete() { |
80 | 106 | $this->dataRecord = $app->tform->getDataRecord($this->id); |
81 | 107 | $client_id = $app->functions->intval($this->dataRecord['client_id']); |
82 | 108 | $client_group = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client_id); |
83 | | - |
84 | | - // Get all records (sub-clients, mail, web, etc....) of this client. |
85 | | - $tables = 'cron,client,dns_rr,dns_soa,dns_slave,ftp_user,mail_access,mail_content_filter,mail_domain,mail_forwarding,mail_get,mail_user,mail_user_filter,shell_user,spamfilter_users,support_message,web_database,web_database_user,web_domain,web_traffic,domain'; |
86 | | - $tables_array = explode(',', $tables); |
87 | | - $client_group_id = $app->functions->intval($client_group['groupid']); |
88 | | - |
89 | 109 | $table_list = array(); |
| 110 | + $client_group_id = $app->functions->intval($client_group['groupid']); |
90 | 111 | if($client_group_id > 1) { |
91 | | - foreach($tables_array as $table) { |
| 112 | + foreach($this->tables as $table => $field) { |
92 | 113 | if($table != '') { |
93 | 114 | $records = $app->db->queryAllRecords("SELECT * FROM ?? WHERE sys_groupid = ?", $table, $client_group_id); |
94 | | - $number = count($records); |
95 | | - if($number > 0) $table_list[] = array('table' => $table."(".$number.")"); |
| 115 | + if(is_array($records) && !empty($records) && $field !== false) { |
| 116 | + $data = array(); |
| 117 | + $number = count($records); |
| 118 | + foreach($records as $rec) { |
| 119 | + if($field != '' && $field !== false) $data['data'] .= '<li>'.$rec[$field].'</li>'; |
| 120 | + } |
| 121 | + $data['count'] = $number; |
| 122 | + $data['table'] = $table; |
| 123 | + $table_list[] = $data; |
| 124 | + } |
96 | 125 | } |
97 | 126 | } |
98 | 127 | } |
99 | 128 |
|
100 | 129 | $app->tpl->setVar('id', $this->id); |
101 | 130 | $app->tpl->setVar('number_records', $number); |
102 | 131 | $app->tpl->setLoop('records', $table_list); |
103 | | - |
104 | 132 | //* load language file |
105 | 133 | $lng_file = 'lib/lang/'.$app->functions->check_language($_SESSION['s']['language']).'_client_del.lng'; |
106 | 134 | include $lng_file; |
@@ -138,18 +166,17 @@ function onBeforeDelete() { |
138 | 166 | $app->db->query("DELETE FROM sys_user WHERE client_id = ?", $client_id); |
139 | 167 |
|
140 | 168 | // Delete all records (sub-clients, mail, web, etc....) of this client. |
141 | | - $tables = 'cron,client,dns_rr,dns_soa,dns_slave,ftp_user,mail_access,mail_content_filter,mail_domain,mail_forwarding,mail_get,mail_user,mail_user_filter,shell_user,spamfilter_users,support_message,web_database,web_database_user,web_domain,web_folder,web_folder_user,domain,mail_mailinglist,spamfilter_wblist'; |
142 | | - $tables_array = explode(',', $tables); |
143 | 169 | $client_group_id = $app->functions->intval($client_group['groupid']); |
144 | 170 | if($client_group_id > 1) { |
145 | | - foreach($tables_array as $table) { |
| 171 | + foreach($this->tables as $table => $field) { |
146 | 172 | if($table != '') { |
147 | 173 | //* find the primary ID of the table |
148 | 174 | $table_info = $app->db->tableInfo($table); |
149 | 175 | $index_field = ''; |
150 | 176 | foreach($table_info as $tmp) { |
151 | 177 | if($tmp['option'] == 'primary') $index_field = $tmp['name']; |
152 | 178 | } |
| 179 | + |
153 | 180 | //* Delete the records |
154 | 181 | if($index_field != '') { |
155 | 182 | $records = $app->db->queryAllRecords("SELECT * FROM ?? WHERE sys_groupid = ? ORDER BY ?? DESC", $table, $client_group_id, $index_field); |
|
0 commit comments