8. rewrite
cronjobs_edit.php
Code:
<?php
/**
* ispCP П‰ (OMEGA) a Virtual Hosting Control System
*
* @copyright 2001-2006 by moleSoftware GmbH
* @copyright 2006-2008 by ispCP | http://isp-control.net
* @version SVN: $Id$
* @link http://isp-control.net
* @author ispCP Team
*
* @license
* This program is free software; you can redistribute it and/or modify it under
* the terms of the MPL General Public License as published by the Free Software
* Foundation; either version 1.1 of the License, or (at your option) any later
* version.
* You should have received a copy of the MPL Mozilla Public License along with
* this program; if not, write to the Open Source Initiative (OSI)
* http://opensource.org | osi@opensource.org
*/
require '../include/ispcp-lib.php';
check_login(__FILE__);
$tpl = new pTemplate();
$tpl->define_dynamic('page', Config::get('CLIENT_TEMPLATE_PATH') . '/cronjobs_edit.tpl');
$tpl->define_dynamic('page_message', 'page');
$tpl->define_dynamic('logged_from', 'page');
$theme_color = Config::get('USER_INITIAL_THEME');
$tpl->assign(
array('TR_CLIENT_CRONJOBS_TITLE' => tr('ispCP - Client/Cronjob Manager'),
'THEME_COLOR_PATH' => "../themes/$theme_color",
'THEME_CHARSET' => tr('encoding'),
'ISP_LOGO' => get_logo($_SESSION['user_id'])
)
);
/* All functions written by Sergey Obookhoff
* (c) 2009
* www.data-stream.ru
* Moscow, Russia
*/
if (!isset($_GET['cron_id']) && !isset($_POST['Submit'])) {
set_page_message(tr('Nothing to do!'));
user_goto('cronjobs_overview.php');
}
if (isset($_GET['cron_id']) && $_GET['cron_id'] !== '') {
$cron_id = $_GET['cron_id'];}
function update_cron_job(&$tpl, &$sql, $cron_id, $user_id) {
foreach($_POST as $key => $value)
{
$a = $key;
$$a = $value;
}
if ($activ == 0) {$cron_status = "ok";}
else {$cron_status = Config::get('ITEM_ADD_STATUS');}
$query = "
UPDATE
cron_jobs
SET
cron_name = ?, cron_desc = ?, min = ?, hour = ?, day = ?, month = ?, week = ?, command = ?, cron_activ = ?, cron_status = ?
WHERE
cron_id = ?
";
$rs = exec_query($sql, $query, array($name, $description, $min, $hour, $day_of_month, $month, $day_of_week, $command_line, $activ, $cron_status,$cron_id));
send_request();
write_log($_SESSION['user_logged'] . ": updeted Cron Job: " . $cron_name);
set_page_message(tr('Cron Job successfully updated!'));
user_goto('cronjobs_overview.php');
} // End of update_cron_job();
function gen_cron_job(&$tpl, &$sql, $cron_id, $user_id) {
$query = "
SELECT
`cron_id`, `admin_id`, `cron_name`, `cron_desc`, `min`, `hour`, `day`, `month`, `week`, `command`, `cron_activ`, `cron_status`
FROM
`cron_jobs`
WHERE
admin_id = $user_id
AND
cron_id = $cron_id
";
$rs = exec_query($sql, $query, array($cron_id));
if ($rs->RecordCount() == 0) {
set_page_message(tr('No CronJob with this ID!'));
header('Location: cronjobs_overview.php');
exit(0);
}
if ($rs->fields['cron_status'] != 'ok') {
set_page_message(tr('Job is shedalled and can not be editing or deleting!'));
header('Location: cronjobs_overview.php');
exit(0);
} else {
if ($rs->fields['cron_activ'] == 1) {$active_yes = 'selected'; $active_no = '';}
else {$active_no = 'selected'; $active_yes = '';}
$tpl->assign(
array('NAME' => $rs->fields['cron_name'],
'DESCRIPTION' => $rs->fields['cron_desc'],
'COMMAND_LINE' => $rs->fields['command'],
'ACTIVE' => $rs->fields['cron_activ'],
'ACTIVE_YES' => $active_yes,
'ACTIVE_NO' => $active_no,
'ID' => $rs->fields['cron_id']
)
);
}
} // End of gen_cron_job();
/*
*
* static page messages.
*
*/
gen_client_mainmenu($tpl, Config::get('CLIENT_TEMPLATE_PATH') . '/main_menu_webtools.tpl');
gen_client_menu($tpl, Config::get('CLIENT_TEMPLATE_PATH') . '/menu_webtools.tpl');
gen_logged_from($tpl);
check_permissions($tpl);
if (isset($_GET['cron_id']) && is_numeric($_GET['cron_id']) && isset($_POST['Submit']))
update_cron_job($tpl, $sql, $_GET['cron_id'], $_SESSION['user_id']);
gen_cron_job($tpl, $sql, $cron_id, $_SESSION['user_id']);
$tpl->assign(
array('TR_CRON_MANAGER' => tr('Cronjob Manager'),
'TR_EDIT_CRONJOB' => tr('Edit Cronjob'),
'TR_NAME' => tr('Name'),
'TR_DESCRIPTION' => tr('Description'),
'TR_ACTIVE' => tr('Active'),
'YES' => tr('Yes'),
'NO' => tr('No'),
'TR_CRONJOB' => tr('Cronjob'),
'TR_COMMAND' => tr('Command to run:'),
'TR_MIN' => tr('Minute(s):'),
'TR_HOUR' => tr('Hour(s):'),
'TR_DAY' => tr('Day(s):'),
'TR_MONTHS' => tr('Month(s):'),
'TR_WEEKDAYS' => tr('Weekday(s):'),
'TR_UPDATE' => tr('Update'),
'TR_CANCEL' => tr('Cancel'),
)
);
gen_page_message($tpl);
$tpl->parse('PAGE', 'page');
$tpl->prnt();
if (Config::get('DUMP_GUI_DEBUG'))
dump_gui_debug();
unset_messages();
?>
9. Opening
cronjobs_edit.tpl and removing buggs
{DESCTIPTON} change to {DESCRIPTION}
action="
cronjobs_edit.php"
changing to
action="
cronjobs_edit.php?cron_id={ID}"
And repllacing code under <td colspan="4" class="content"><select name="activ">
to
<option value="1" {ACTIVE_YES}>{YES}</option>
<option value="0" {ACTIVE_NO}>{NO}</option>
And becouse multi selection not supported we must delete all multiple="multiple"
And in crongobs_add.tpl too.
But in other highlit selections we have a big truble
Code sample
if ($rs->fields['cron_activ'] == 1) {$active_yes = 'selected'; $active_no = '';}
else {$active_no = 'selected'; $active_yes = '';}
......
'ACTIVE_YES' => $active_yes,
'ACTIVE_NO' => $active_no,
And in the template
<option value="1" {ACTIVE_YES}>{YES}</option>
<option value="0" {ACTIVE_NO}>{NO}</option>
It's not good solution for lage selection feeld in forms.
Any idea?
May be in Java...
And now we have full-function web interfeice to mySQL
But we must convert add mySQL table to the cron files.
And we must write sub for ispcp-rqst-mngr
Any perl Coders are preasent, is not it?
Who is next developer for this function?