From: Florian G. <re...@us...> - 2006-12-29 23:19:26
|
Update of /cvsroot/perfparse/_perfparse-phpgui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20553 Modified Files: perfparse.php utils.php Log Message: finalized edit delete policies dialog Index: utils.php =================================================================== RCS file: /cvsroot/perfparse/_perfparse-phpgui/utils.php,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** utils.php 29 Dec 2006 00:27:06 -0000 1.32 --- utils.php 29 Dec 2006 23:19:24 -0000 1.33 *************** *** 499,502 **** --- 499,510 ---- } + function get_delete_policy(&$db,$id) { + $query='select policy_id,policy_name,delete_policy_seconds,policy_comment + from perfdata_delete_policy where policy_id=?'; + $res=$db->GetRow($query,array($id)); + return($res); + } + + function create_delete_policy(&$db,$policy,$seconds,$comment='') { $query='insert into perfdata_delete_policy *************** *** 506,509 **** --- 514,525 ---- } + function edit_delete_policy(&$db,$id,$policy,$seconds,$comment='') { + $query='update perfdata_delete_policy set + policy_name=?, policy_comment=?, delete_policy_seconds=? + where policy_id=?'; + $db->Execute($query,array($policy,$comment,$seconds,$id)); + return($db->ErrorNo()); + } + function delete_delete_policy(&$db,$policy_id) { $query='delete from perfdata_delete_policy where policy_id=?'; Index: perfparse.php =================================================================== RCS file: /cvsroot/perfparse/_perfparse-phpgui/perfparse.php,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** perfparse.php 29 Dec 2006 00:27:06 -0000 1.44 --- perfparse.php 29 Dec 2006 23:19:24 -0000 1.45 *************** *** 490,496 **** break; case 'edit_delete_policies': ! // handle create policy template: get_request_var('create_policy','string',''); ! if(!empty($create_policy)) { get_request_var('create_policy_comment','string',''); get_request_var('create_policy_days','int',0); --- 490,509 ---- break; case 'edit_delete_policies': ! // handle create or edit policy template: ! get_request_var('edit_policy','int',false); get_request_var('create_policy','string',''); ! if(empty($create_policy) && $edit_policy != false) { ! $epolicy=get_delete_policy($db,$edit_policy); ! $s=$epolicy['delete_policy_seconds']; ! $epolicy['policy_seconds']=$s%60; ! $s=floor($s/60); ! $epolicy['policy_minutes']=$s%60; ! $s=floor($s/60); ! $epolicy['policy_hours']=$s%24; ! $epolicy['policy_days']=floor($s/24); ! $smarty->assign_by_ref('epolicy',$epolicy); ! // echo "epolicy:<pre>";print_r($epolicy);echo "</pre>"; ! $smarty->assign('edit_policy',$edit_policy); ! } elseif(!empty($create_policy)) { get_request_var('create_policy_comment','string',''); get_request_var('create_policy_days','int',0); *************** *** 502,507 **** 3600*$create_policy_hours+ 86400*$create_policy_days; ! if(create_delete_policy($db,$create_policy,$create_policy_seconds,$create_policy_comment)!=0) { ! $smarty->assign('sql_error',$db->ErrorMsg()); } } --- 515,528 ---- 3600*$create_policy_hours+ 86400*$create_policy_days; ! if($edit_policy != false) { ! // policy was edited ! if(edit_delete_policy($db,$edit_policy,$create_policy,$create_policy_seconds,$create_policy_comment)!=0) { ! $smarty->assign('sql_error',$db->ErrorMsg()); ! } ! } else { ! // policy was created ! if(create_delete_policy($db,$create_policy,$create_policy_seconds,$create_policy_comment)!=0) { ! $smarty->assign('sql_error',$db->ErrorMsg()); ! } } } *************** *** 515,518 **** --- 536,540 ---- } + // load infos for display $policies=get_delete_policies($db); |