commit | author | age
|
524077
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
|
4 |
Copyright (c) 2011, Till Brehm, projektfarm Gmbh |
|
5 |
Modified 2009, Marius Cramer, pixcept KG |
|
6 |
All rights reserved. |
|
7 |
|
|
8 |
Redistribution and use in source and binary forms, with or without modification, |
|
9 |
are permitted provided that the following conditions are met: |
|
10 |
|
|
11 |
* Redistributions of source code must retain the above copyright notice, |
|
12 |
this list of conditions and the following disclaimer. |
|
13 |
* Redistributions in binary form must reproduce the above copyright notice, |
|
14 |
this list of conditions and the following disclaimer in the documentation |
|
15 |
and/or other materials provided with the distribution. |
|
16 |
* Neither the name of ISPConfig nor the names of its contributors |
|
17 |
may be used to endorse or promote products derived from this software without |
|
18 |
specific prior written permission. |
|
19 |
|
|
20 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
|
21 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
22 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
23 |
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
|
24 |
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
25 |
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
26 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
27 |
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
28 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
|
29 |
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
30 |
*/ |
|
31 |
|
|
32 |
/****************************************** |
|
33 |
* Begin Form configuration |
|
34 |
******************************************/ |
|
35 |
|
|
36 |
$tform_def_file = "form/web_folder.tform.php"; |
|
37 |
|
|
38 |
/****************************************** |
|
39 |
* End Form configuration |
|
40 |
******************************************/ |
|
41 |
|
7fe908
|
42 |
require_once '../../lib/config.inc.php'; |
MC |
43 |
require_once '../../lib/app.inc.php'; |
524077
|
44 |
|
T |
45 |
//* Check permissions for module |
|
46 |
$app->auth->check_module_permissions('sites'); |
|
47 |
|
|
48 |
// Loading classes |
|
49 |
$app->uses('tpl,tform,tform_actions,validate_cron'); |
|
50 |
$app->load('tform_actions'); |
|
51 |
|
|
52 |
class page_action extends tform_actions { |
|
53 |
|
|
54 |
function onSubmit() { |
|
55 |
global $app, $conf; |
7fe908
|
56 |
|
524077
|
57 |
// Get the record of the parent domain |
2af58c
|
58 |
$parent_domain = $app->db->queryOneRecord("select * FROM web_domain WHERE domain_id = ? AND ".$app->tform->getAuthSQL('r'), @$this->dataRecord["parent_domain_id"]); |
7fe908
|
59 |
if(!$parent_domain || $parent_domain['domain_id'] != @$this->dataRecord['parent_domain_id']) $app->tform->errorMessage .= $app->tform->lng("no_domain_perm"); |
MC |
60 |
|
524077
|
61 |
// Set a few fixed values |
T |
62 |
$this->dataRecord["server_id"] = $parent_domain["server_id"]; |
f4de70
|
63 |
|
FT |
64 |
// make sure this folder isn't protected already |
|
65 |
if($this->id > 0){ |
2af58c
|
66 |
$folder = $app->db->queryOneRecord("SELECT * FROM web_folder WHERE parent_domain_id = ? AND path = ? AND web_folder_id != ?", $this->dataRecord['parent_domain_id'], $this->dataRecord['path'], $this->id); |
f4de70
|
67 |
} else { |
2af58c
|
68 |
$folder = $app->db->queryOneRecord("SELECT * FROM web_folder WHERE parent_domain_id = ? AND path = ?", $this->dataRecord['parent_domain_id'], $this->dataRecord['path']); |
f4de70
|
69 |
} |
FT |
70 |
if(is_array($folder) && !empty($folder)) $app->tform->errorMessage .= $app->tform->lng('error_folder_already_protected_txt'); |
7fe908
|
71 |
|
524077
|
72 |
parent::onSubmit(); |
T |
73 |
} |
f4de70
|
74 |
|
FT |
75 |
function onAfterInsert() { |
|
76 |
global $app, $conf; |
|
77 |
|
2af58c
|
78 |
$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $this->dataRecord["parent_domain_id"]); |
f4de70
|
79 |
|
FT |
80 |
// The web folder entry shall be owned by the same group as the website |
|
81 |
$sys_groupid = $app->functions->intval($web['sys_groupid']); |
|
82 |
|
2af58c
|
83 |
$sql = "UPDATE web_folder SET sys_groupid = ? WHERE web_folder_id = ?"; |
MC |
84 |
$app->db->query($sql, $sys_groupid, $this->id); |
f4de70
|
85 |
} |
FT |
86 |
|
|
87 |
function onAfterUpdate() { |
|
88 |
global $app, $conf; |
|
89 |
|
|
90 |
//* When the site of the web folder has been changed |
|
91 |
if(isset($this->dataRecord['parent_domain_id']) && $this->oldDataRecord['parent_domain_id'] != $this->dataRecord['parent_domain_id']) { |
2af58c
|
92 |
$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $this->dataRecord["parent_domain_id"]); |
f4de70
|
93 |
|
FT |
94 |
// The web folder entry shall be owned by the same group as the website |
|
95 |
$sys_groupid = $app->functions->intval($web['sys_groupid']); |
|
96 |
|
2af58c
|
97 |
$sql = "UPDATE web_folder SET sys_groupid = ? WHERE web_folder_id = ?"; |
MC |
98 |
$app->db->query($sql, $sys_groupid, $this->id); |
f4de70
|
99 |
} |
FT |
100 |
|
|
101 |
} |
7fe908
|
102 |
|
524077
|
103 |
} |
T |
104 |
|
|
105 |
$page = new page_action; |
|
106 |
$page->onLoad(); |
|
107 |
|
7fe908
|
108 |
?> |