Skip to content

Commit cb23b73

Browse files
committed
Update the placeholders when changing domains
However, detection of cron_type needs some work
1 parent 3ac0d7c commit cb23b73

File tree

4 files changed

+66
-15
lines changed

4 files changed

+66
-15
lines changed

interface/web/sites/ajax_get_json.php

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
$php_type = $_GET["php_type"];
4242
$client_group_id = $app->functions->intval($_GET['client_group_id']);
4343
$type = $_GET["type"];
44+
$cron_type = $_GET["cron_type"];
4445

4546
//if($_SESSION["s"]["user"]["typ"] == 'admin') {
4647

@@ -248,7 +249,36 @@
248249
$json = $app->functions->json_encode($client);
249250
}
250251

251-
//}
252+
if($type == 'getcronplaceholders') {
253+
254+
$web = $app->db->queryOneRecord("SELECT `domain`, `document_root`, `php_cli_binary`
255+
FROM `web_domain`
256+
LEFT JOIN server_php ON web_domain.server_php_id = server_php.server_php_id
257+
WHERE `domain_id` = ? AND ".$app->tform->getAuthSQL('r'), $web_id);
258+
259+
260+
261+
if($cron_type != 'chrooted') {
262+
$web_docroot_client = $web['document_root'];
263+
} else {
264+
$web_docroot_client = '';
265+
}
266+
267+
if(empty($web['php_cli_binary'])) {
268+
$web['php_cli_binary'] = "/usr/bin/php";
269+
}
270+
271+
$web_docroot_client .= '/web';
272+
273+
$json = json_encode(array(
274+
'php_cli_binary' => $web['php_cli_binary'],
275+
'docroot_client' => $web_docroot_client,
276+
'domain' => $web['domain']
277+
));
278+
279+
280+
281+
}
252282

253283
header('Content-type: application/json');
254284
echo $json;

interface/web/sites/cron_edit.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,20 @@ function onShowEnd() {
7979
}
8080

8181
$parent_domain = $app->db->queryOneRecord("SELECT `domain_id`, `system_user`, `system_group`, `domain`, `document_root`, `hd_quota`, `php_cli_binary`
82-
FROM `web_domain`
83-
LEFT JOIN server_php ON web_domain.server_php_id = server_php.server_php_id
84-
WHERE `domain_id` = ?", $this->dataRecord["parent_domain_id"]);
82+
FROM `web_domain`
83+
LEFT JOIN server_php ON web_domain.server_php_id = server_php.server_php_id
84+
WHERE `domain_id` = ?", $this->dataRecord["parent_domain_id"]);
8585

86-
if(!$parent_domain["domain_id"]) {
87-
$app->log("Parent domain not found", LOGLEVEL_WARN);
88-
return 0;
89-
}
90-
91-
$web_docroot_client = '';
9286

9387
if($this->dataRecord['type'] != 'chrooted') {
94-
$web_docroot_client = $this->parent_domain['document_root'];
88+
$web_docroot_client = $parent_domain['document_root'];
89+
} else {
90+
$web_docroot_client = '';
9591
}
9692

93+
//TODO: Fix cron type detection
94+
$app->tpl->setVar("cron_type", $this->dataRecord['type']);
95+
9796
// web folder is hardcoded to /web:
9897
$web_docroot_client .= '/web';
9998

@@ -153,6 +152,7 @@ function onSubmit() {
153152
}
154153
}
155154

155+
156156
parent::onSubmit();
157157
}
158158

interface/web/sites/lib/lang/de_cron.lng

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $wb['run_wday_error_format'] = 'Das Format für Wochentage ist nicht korrekt.';
1919
$wb['command_error_format'] = 'Das Format für den Befehl ist nicht korrekt. Beachten Sie, dass bei einem URL Aufruf nur http und https erlaubt ist.';
2020
$wb['unknown_fieldtype_error'] = 'Es wurde ein unbekanntes Feld verwendet.';
2121
$wb['server_id_error_empty'] = 'Die Server-ID ist leer.';
22-
$wb['command_hint_txt'] = 'z. B. /var/www/clients/clientX/webY/myscript.sh oder https://www.mydomain.com/path/script.php. Der Platzhalter [web_root] wird durch /var/www/clients/clientX/webY/web ersetzt.';
22+
$wb['command_hint_txt'] = 'z.B. /var/www/clients/clientX/webY/myscript.sh oder https://www.mydomain.com/path/script.php, können Sie die obigen Platzhalter einfügen, die dann durch ihren Wert ersetzt werden. Bewegen Sie den Mauszeiger über die Variable, um den erwarteten Wert zu sehen.';
2323
$wb['log_output_txt'] = 'Ausgabe loggen';
2424
$wb['limit_cron_url_txt'] = 'Es sind nur URL cronjobs möglich. Der Cron-Befehl muss mit https:// beginnen.';
2525
$wb['command_error_empty'] = 'Befehl ist leer.';

interface/web/sites/templates/cron_edit.htm

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@
5252
<div class="col-sm-9">
5353
<input type="text" name="command" id="command" value="{tmpl_var name='command'}" class="form-control" />
5454
<b>{tmpl_var name='variables_txt'}:</b>
55-
<a href="javascript:void(0);" data-toggle="tooltip" title="{tmpl_var name='php_cli_binary'}" class="addPlaceholder">{SITE_PHP}</a>,
56-
<a href="javascript:void(0);" data-toggle="tooltip" title="{tmpl_var name='docroot_client'}" class="addPlaceholder">{DOCROOT_CLIENT}</a>,
57-
<a href="javascript:void(0);" data-toggle="tooltip" title="{tmpl_var name='domain'}" class="addPlaceholder">{DOMAIN}</a>
55+
<a href="javascript:void(0);" data-toggle="tooltip" id="php_cli_binary" title="{tmpl_var name='php_cli_binary'}" class="addPlaceholder">{SITE_PHP}</a>,
56+
<a href="javascript:void(0);" data-toggle="tooltip" id="docroot_client" title="{tmpl_var name='docroot_client'}" class="addPlaceholder">{DOCROOT_CLIENT}</a>,
57+
<a href="javascript:void(0);" data-toggle="tooltip" id="domain" title="{tmpl_var name='domain'}" class="addPlaceholder">{DOMAIN}</a>
5858
<br><br><p class="formHint">{tmpl_var name='command_hint_txt'}</p>
5959
</div>
6060
</div>
@@ -73,8 +73,29 @@
7373

7474

7575
<input type="hidden" name="id" value="{tmpl_var name='id'}">
76+
<input type="hidden" name="cron_type" value="{tmpl_var name='cron_type'}">
7677

7778
<div class="clear"><div class="right">
7879
<button class="btn btn-default formbutton-success" type="button" value="{tmpl_var name='btn_save_txt'}" data-submit-form="pageForm" data-form-action="sites/cron_edit.php">{tmpl_var name='btn_save_txt'}</button>
7980
<button class="btn btn-default formbutton-default" type="button" value="{tmpl_var name='btn_cancel_txt'}" data-load-content="sites/cron_list.php">{tmpl_var name='btn_cancel_txt'}</button>
8081
</div></div>
82+
83+
<script language="JavaScript" type="text/javascript">
84+
jQuery('#parent_domain_id').change(function(){
85+
reloadCronPlaceholders();
86+
});
87+
88+
function reloadCronPlaceholders() {
89+
var parentDomainId = jQuery('#parent_domain_id').val()
90+
var cron_type = jQuery('#cron_type').val()
91+
92+
jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {web_id: parentDomainId, cron_type: cron_type, 'type': 'getcronplaceholders'}, function(data) {
93+
console.log(data);
94+
$("#php_cli_binary").attr('data-original-title', data.php_cli_binary);
95+
$('#docroot_client').attr('data-original-title', data.docroot_client);
96+
$('#domain').attr('data-original-title', data.domain);
97+
98+
});
99+
}
100+
</script>
101+

0 commit comments

Comments
 (0)