From 2f3c1099996bca8c050b452852d52d91cb6be3f6 Mon Sep 17 00:00:00 2001 From: osmiy Date: Thu, 26 Jan 2006 16:08:54 +0000 Subject: - Frontend improvements (Eugene) git-svn-id: svn://svn.zabbix.com/trunk@2565 97f52cf1-0a1b-0410-bd0e-c28be96e8082 --- frontends/php/actionconf.php | 168 +++++++++----------- frontends/php/css.css | 9 ++ frontends/php/hosts.php | 19 +-- frontends/php/include/actions.inc.php | 20 +-- frontends/php/include/classes/ccheckbox.inc.php | 9 +- frontends/php/include/classes/ccombobox.inc.php | 16 +- frontends/php/include/forms.inc.php | 198 +++++++++++++----------- frontends/php/media.php | 89 ++++++----- 8 files changed, 271 insertions(+), 257 deletions(-) (limited to 'frontends/php') diff --git a/frontends/php/actionconf.php b/frontends/php/actionconf.php index b0069e4e..0f4f1576 100644 --- a/frontends/php/actionconf.php +++ b/frontends/php/actionconf.php @@ -28,6 +28,8 @@ ?> AddItem(0,S_SEND_MESSAGE); + $cmbType->AddItem(1,S_REMOTE_COMMAND,NULL,'no'); + $form->AddItem($cmbType); + + $form->AddItem(" | "); + $form->AddItem(new CButton("form",S_CREATE_ACTION)); -# $h2=S_GROUP." "; - $h2=""; - $h2=$h2.""; + show_header2(S_ACTIONS, $form); - $h2=$h2." | "; - $h2=$h2.""; - show_header2($h1, $h2, "
", "
"); $tblActions = new CTableInfo(S_NO_ACTIONS_DEFINED); - $tblActions->SetHeader(array(S_SOURCE,S_CONDITIONS,S_SEND_MESSAGE_TO,S_DELAY,S_SUBJECT,S_REPEATS,S_ACTIONS)); + $tblActions->SetHeader(array(S_SOURCE,S_CONDITIONS,S_SEND_MESSAGE_TO, + S_DELAY,S_SUBJECT,S_REPEATS,S_ACTIONS)); if(isset($_REQUEST["actiontype"])&&($_REQUEST["actiontype"]==1)) { @@ -198,12 +177,13 @@ $result=DBselect($sql); while($row=DBfetch($result)) { - $sql="select * from conditions where actionid=".$row["actionid"]." order by conditiontype"; - $result2=DBselect($sql); $conditions=""; + $result2=DBselect("select * from conditions where actionid=".$row["actionid"]. + " order by conditiontype"); while($condition=DBfetch($result2)) { - $conditions=$conditions.get_condition_desc($condition["conditiontype"],$condition["operator"],$condition["value"])."
"; + $conditions=$conditions.get_condition_desc($condition["conditiontype"], + $condition["operator"],$condition["value"]).BR; } if($row["recipient"] == RECIPIENT_TYPE_USER) diff --git a/frontends/php/css.css b/frontends/php/css.css index 95335882..c456f061 100644 --- a/frontends/php/css.css +++ b/frontends/php/css.css @@ -269,6 +269,15 @@ tr.table_even_row:hover { color: #00AA00; } +A.enabled:link { color:#00AA00; text-decoration: none; } +A.enabled:visited { color:#00AA00; text-decoration: none; } +A.enabled:hover { color:#00AA00; text-decoration: underline; } +A.enabled:active { color:#00AA00; text-decoration: underline;} + +A.disabled:link { color:#AA0000; text-decoration: none; } +A.disabled:visited { color:#AA0000; text-decoration: none; } +A.disabled:hover { color:#AA0000; text-decoration: underline; } +A.disabled:active { color:#AA0000; text-decoration: underline;} A.off:link { color:#00AA00; text-decoration: none; } A.off:visited { color:#00AA00; text-decoration: none; } diff --git a/frontends/php/hosts.php b/frontends/php/hosts.php index 292c28c9..48e7306f 100644 --- a/frontends/php/hosts.php +++ b/frontends/php/hosts.php @@ -317,13 +317,13 @@ $result=update_template_linkage($_REQUEST["hosttemplateid"],$_REQUEST["hostid"],$_REQUEST["templateid"],$items,$triggers,$graphs); show_messages($result, S_TEMPLATE_LINKAGE_UPDATED, S_CANNOT_UPDATE_TEMPLATE_LINKAGE); } - if($_REQUEST["register"]=="delete linkage") - { - $result=delete_template_linkage($_REQUEST["hosttemplateid"]); - show_messages($result, S_TEMPLATE_LINKAGE_DELETED, S_CANNOT_DELETE_TEMPLATE_LINKAGE); - unset($_REQUEST["hosttemplateid"]); - } } + if($_REQUEST["config"]==2&&isset($_REQUEST["delete"])&&isset($_REQUEST["hosttemplateid"])) + { + $result=delete_template_linkage($_REQUEST["hosttemplateid"]); + show_messages($result, S_TEMPLATE_LINKAGE_DELETED, S_CANNOT_DELETE_TEMPLATE_LINKAGE); + unset($_REQUEST["hosttemplateid"]); + } ?> @@ -419,7 +419,7 @@ if(isset($_REQUEST["hostid"])) { echo BR; - @insert_template_form($_REQUEST["hostid"], $_REQUEST["hosttemplateid"]); + insert_template_form(); echo BR; $table = new CTableInfo(S_NO_LINKAGES_DEFINED); @@ -430,7 +430,6 @@ { $host=get_host_by_hostid($row["hostid"]); $template=get_host_by_hostid($row["templateid"]); - $actions="".S_CHANGE.""; $table->addRow(array( $host["host"], @@ -438,7 +437,9 @@ get_template_permission_str($row["items"]), get_template_permission_str($row["triggers"]), get_template_permission_str($row["graphs"]), - $actions + new CLink(S_CHANGE, "hosts.php?form=0".url_param("config"). + "&hostid=".$row["hostid"]. + "&hosttemplateid=".$row["hosttemplateid"]) )); } $table->show(); diff --git a/frontends/php/include/actions.inc.php b/frontends/php/include/actions.inc.php index e2180fce..621d9adc 100644 --- a/frontends/php/include/actions.inc.php +++ b/frontends/php/include/actions.inc.php @@ -36,7 +36,7 @@ # Add Action - function add_action( $userid, $delay, $subject, $message, $recipient, $usrgrpid, $maxrepeats, $repeatdelay) + function add_action( $id, $delay, $subject, $message, $recipient, $maxrepeats, $repeatdelay) { // if(!check_right_on_trigger("A",$triggerid)) // { @@ -44,15 +44,6 @@ // return 0; // } - if($recipient == RECIPIENT_TYPE_USER) - { - $id = $userid; - } - else - { - $id = $usrgrpid; - } - $sql="insert into actions (userid,delay,nextcheck,subject,message,recipient,maxrepeats,repeatdelay) values ($id,$delay,0,'$subject','$message',$recipient,$maxrepeats,$repeatdelay)"; $result=DBexecute($sql); return DBinsert_id($result,"actions","actionid"); @@ -150,8 +141,13 @@ while($row2=DBfetch($result2)) { $host=get_host_by_hostid($row["hostid"]); - $message=str_replace("{".$host_template["host"].":", "{".$host["host"].":", $action["message"]); - add_action($row2["triggerid"], $action["userid"], $action["good"], $action["delay"], $action["subject"], $message, $action["scope"], $action["severity"], $action["recipient"], $action["userid"], $action["maxrepeats"],$action["repeatdelay"]); + $message=str_replace("{".$host_template["host"].":", "{".$host["host"].":", + $action["message"]); + + add_action($row2["triggerid"], $action["userid"], $action["good"], + $action["delay"], $action["subject"], $message, $action["scope"], + $action["severity"], $action["recipient"], $action["maxrepeats"], + $action["repeatdelay"]); } } } diff --git a/frontends/php/include/classes/ccheckbox.inc.php b/frontends/php/include/classes/ccheckbox.inc.php index 36fe3962..01bd4d36 100644 --- a/frontends/php/include/classes/ccheckbox.inc.php +++ b/frontends/php/include/classes/ccheckbox.inc.php @@ -51,10 +51,15 @@ } function SetChecked($value="yes") { - if($value=="yes" || $value=="checked" || $value=="on" || $value==1) + if(is_null($value)){ + return 0; + }elseif((is_string($value)&&($value=="yes" || $value=="checked" || $value=="on")) + || (is_int($value)&&$value<>0)){ return $this->AddOption("checked","checked"); - elseif($value=="no" || $value=="unchecked" || $value=="off" || $value==NULL || $value==0) + }elseif((is_string($value)&&($value=="no" || $value=="unchecked" || $value=="off")) + || (is_int($value)&&$value==0)){ return $this->DelOption("checked"); + } return $this->error("Incorrect value for SetChacked [$value]"); } function SetAction($value='submit()', $event='onClick') diff --git a/frontends/php/include/classes/ccombobox.inc.php b/frontends/php/include/classes/ccombobox.inc.php index e05c8ea5..cecb45c3 100644 --- a/frontends/php/include/classes/ccombobox.inc.php +++ b/frontends/php/include/classes/ccombobox.inc.php @@ -46,17 +46,25 @@ } function SetEnable($value='yes') { - if($value == 'yes' || $value == 'enabled' || $value=='on') + if(is_null($value)) + return 0; + elseif((is_string($value) && ($value == 'yes' || $value == 'enabled' || $value=='on')) + || (is_int($value) && $value<>0)) return $this->DelOption('disabled'); - elseif($value == 'no' || $value == 'disabled' || $value=='off' || $value == NULL) + elseif((is_string($value) && ($value == 'no' || $value == 'disabled' || $value=='off')) + || (is_int($value) && $value==0)) return $this->AddOption('disabled','disabled'); return $this->error("Incorrect value for SetEnable [$value]"); } function SetSelected($value='yes') { - if($value == 'yes' || $value == "selected" || $value=='on') + if(is_null($value)) + return 0; + elseif((is_string($value) && ($value == 'yes' || $value == "selected" || $value=='on')) + || (is_int($value) && $value<>0)) return $this->AddOption('selected','selected'); - elseif($value == 'no' || $value=='off' || $value == NULL) + elseif((is_string($value) && ($value == 'no' || $value=='off')) + || (is_int($value) && $value==0)) return $this->DelOption('selected'); return $this->error("Incorrect value for SetSelected [$value]"); } diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index d598f447..dbd3cb57 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -24,41 +24,45 @@ // include_once "include/local_en.inc.php"; # Insert host template form - function insert_template_form($hostid, $hosttemplateid) + function insert_template_form() { - if(isset($hosttemplateid)) + global $_REQUEST; + + $frmTemplate = new CFormTable(S_TEMPLATE,'hosts.php'); + $frmTemplate->SetHelp('web.hosts.php'); + $frmTemplate->AddVar('config',$_REQUEST["config"]); + + if(isset($_REQUEST["hosttemplateid"])&&$_REQUEST["form"]!=1) { - $result=DBselect("select * from hosts_templates where hosttemplateid=$hosttemplateid"); + $frmTemplate->AddVar('hosttemplateid',$_REQUEST["hosttemplateid"]); + $result=DBselect("select * from hosts_templates". + " where hosttemplateid=".$_REQUEST["hosttemplateid"]); $row=DBfetch($result); - $hostid=$row["hostid"]; - $host=get_host_by_hostid($hostid); - $templateid=$row["templateid"]; - $template=get_host_by_hostid($templateid); - $items=$row["items"]; - $triggers=$row["triggers"]; - $graphs=$row["graphs"]; + $hostid = $row["hostid"]; + $templateid = $row["templateid"]; + $items = $row["items"]; + $triggers = $row["triggers"]; + $graphs = $row["graphs"]; } else { - $hostid=0; - $templateid=0; - $items=7; - $triggers=7; - $graphs=7; + $hostid = get_request("hostid",0); + $templateid = get_request("templateid",0); + $items = get_request("items",7); + $triggers = get_request("triggers",7); + $graphs = get_request("graphs",7); + } + if($hostid!=0){ + $host = get_host_by_hostid($hostid); + $frmTemplate->AddVar('hostid',$hostid); } -# create form - $frmTemplate = new CFormTable(S_TEMPLATE,'hosts.php'); - $frmTemplate->SetHelp('web.hosts.php'); -# init vars - $frmTemplate->AddVar('config',$_REQUEST["config"]); - if($hostid!=0) $frmTemplate->AddVar('hostid',$hostid); - if(isset($hosttemplateid)) $frmTemplate->AddVar('hosttemplateid',$_REQUEST["hosttemplateid"]); -# init rows - $cmbTemplate = new CComboBox('templateid',$templateid); + if($templateid!=0) + $template= get_host_by_hostid($templateid); + $cmbTemplate = new CComboBox('templateid',$templateid); $hosts=DBselect("select hostid,host from hosts order by host"); while($host=DBfetch($hosts)) $cmbTemplate->AddItem($host["hostid"],$host["host"]); @@ -84,13 +88,16 @@ )); $frmTemplate->AddItemToBottomRow(new CButton('register','add linkage')); - if(isset($hosttemplateid)) + if(isset($_REQUEST["hosttemplateid"])) { $frmTemplate->AddItemToBottomRow(SPACE); $frmTemplate->AddItemToBottomRow(new CButton('register','update linkage')); $frmTemplate->AddItemToBottomRow(SPACE); - $frmTemplate->AddItemToBottomRow(new CButton('register','delete linkage',"return Confirm('Delete selected linkage?');")); + $frmTemplate->AddItemToBottomRow(new CButtonDelete('Delete selected linkage?', + url_param("config").url_param("hostid").url_param("hosttemplateid"))); } + $frmTemplate->AddItemToBottomRow(SPACE); + $frmTemplate->AddItemToBottomRow(new CButtonCancel(url_param("config").url_param("hostid"))); $frmTemplate->Show(); } @@ -951,7 +958,7 @@ $frmAction = new CFormTable(S_ACTION,'actionconf.php'); $frmAction->SetHelp('web.actions.action'); - $conditiontype=@iif(isset($_REQUEST["conditiontype"]),$_REQUEST["conditiontype"],0); + $conditiontype = get_request("conditiontype",0); if(isset($_REQUEST["actionid"])) { @@ -961,16 +968,16 @@ if(isset($_REQUEST["actionid"])&&$_REQUEST["form"]!=1) { - $actiontype=$action["actiontype"]; - $source=$action["source"]; - $delay=$action["delay"]; - $uid=$action["userid"]; - // Otherwise symbols like ",' will not be shown - $subject=htmlspecialchars($action["subject"]); - $message=$action["message"]; - $recipient=@iif(isset($_REQUEST["recipient"]),$_REQUEST["recipient"],$action["recipient"]); - $maxrepeats=$action["maxrepeats"]; - $repeatdelay=$action["repeatdelay"]; + $actiontype = $action["actiontype"]; + $source = $action["source"]; + $delay = $action["delay"]; + $uid = $action["userid"]; + $subject = $action["subject"]; + $message = $action["message"]; + $recipient = $action["recipient"]; + $maxrepeats = $action["maxrepeats"]; + $repeatdelay = $action["repeatdelay"]; + if(isset($_REQUEST["repeat"])) { $repeat=$_REQUEST["repeat"]; @@ -996,23 +1003,23 @@ } else { - $source=get_request("source",0); - $actiontype=get_request("actiontype",0); + $source = get_request("source",0); + $actiontype = get_request("actiontype",0); - $delay=get_request("delay",30); - $subject=get_request("subject","{TRIGGER.NAME}: {STATUS}"); - $message=get_request("message","{TRIGGER.NAME}: {STATUS}"); - $scope=get_request("scope",0); - $recipient=get_request("recipient",RECIPIENT_TYPE_GROUP); - $severity=get_request("severity",0); - $maxrepeats=get_request("maxrepeats",0); - $repeatdelay=get_request("repeatdelay",600); - $repeat=get_request("repeat",0); + $delay = get_request("delay",30); + $subject = get_request("subject","{TRIGGER.NAME}: {STATUS}"); + $message = get_request("message","{TRIGGER.NAME}: {STATUS}"); + $scope = get_request("scope",0); + $recipient = get_request("recipient",RECIPIENT_TYPE_GROUP); + $severity = get_request("severity",0); + $maxrepeats = get_request("maxrepeats",0); + $repeatdelay = get_request("repeatdelay",600); + $repeat = get_request("repeat",0); if($recipient==RECIPIENT_TYPE_GROUP) - $uid=get_request("usrgrpid",NULL); + $uid = get_request("usrgrpid",NULL); else - $uid=get_request("userid",NULL); + $uid = get_request("userid",NULL); } @@ -1021,18 +1028,14 @@ for($i=1; $i<=1000; $i++) { if(!isset($_REQUEST["conditiontype$i"])) continue; - array_push($cond_el, - new CCheckBox( - "conditionchecked$i", - 'no', + array_push($cond_el, new CCheckBox( + "conditionchecked$i", 'no', get_condition_desc( $_REQUEST["conditiontype$i"], $_REQUEST["conditionop$i"], $_REQUEST["conditionvalue$i"] - ) - ), - BR - ); + )),BR + ); $frmAction->AddVar("conditiontype$i", $_REQUEST["conditiontype$i"]); $frmAction->AddVar("conditionop$i", $_REQUEST["conditionop$i"]); $frmAction->AddVar("conditionvalue$i", $_REQUEST["conditionvalue$i"]); @@ -1110,24 +1113,24 @@ $txtCondVal = new CTextBox('host','',20); $txtCondVal->SetReadonly('yes'); - $btnSelect = new CButton('btn1','Select',"window.open('popup.php?form=action&field1=value&field2=host','new_win','width=450,height=450,resizable=1,scrollbars=1');"); + $btnSelect = new CButton('btn1','Select', + "window.open('popup.php?form=action&field1=value&field2=host',". + "'new_win','width=450,height=450,resizable=1,scrollbars=1');"); $btnSelect->SetAccessKey('T'); array_push($rowCondition, $txtCondVal, $btnSelect); -// $cmbCondVal = new CComboBox('value'); -// $hosts = DBselect("select hostid,host from hosts order by host"); -// while($host = DBfetch($hosts)) -// { -// $cmbCondVal->AddItem($host["hostid"],$host["host"]); -// } } else if($conditiontype == CONDITION_TYPE_TRIGGER) { $cmbCondVal = new CComboBox('value'); - $triggers = DBselect("select distinct h.host,t.triggerid,t.description from triggers t, functions f,items i, hosts h where t.triggerid=f.triggerid and f.itemid=i.itemid and h.hostid=i.hostid order by h.host"); + $triggers = DBselect("select distinct h.host,t.triggerid,t.description". + " from triggers t, functions f,items i, hosts h". + " where t.triggerid=f.triggerid and f.itemid=i.itemid". + " and h.hostid=i.hostid order by h.host"); while($trigger = DBfetch($triggers)) { - $cmbCondVal->AddItem($trigger["triggerid"],$trigger["host"].": ".$trigger["description"]); + $cmbCondVal->AddItem($trigger["triggerid"], + $trigger["host"].": ".$trigger["description"]); } array_push($rowCondition,$cmbCondVal); } @@ -1218,16 +1221,17 @@ $frmAction->AddRow(S_DELAY_BETWEEN_REPEATS, new CTextBox('repeatdelay',$repeatdelay,2)); } + $frmAction->AddItemToBottomRow(new CButton('save',S_SAVE)); if(isset($_REQUEST["actionid"])) { - $frmAction->AddItemToBottomRow(new CButton('register','update')); $frmAction->AddItemToBottomRow(SPACE); - $frmAction->AddItemToBottomRow(new CButton('register','delete','return Confirm("Delete selected action?");')); + $frmAction->AddItemToBottomRow(new CButtonDelete("Delete selected action?", + url_param("actiontype").url_param("actionid")."&subject=".$subject)); + } else { - $frmAction->AddItemToBottomRow(new CButton('register','add')); } $frmAction->AddItemToBottomRow(SPACE); - $frmAction->AddItemToBottomRow(new CButton('register','cancel')); + $frmAction->AddItemToBottomRow(new CButtonCancel(url_param("actiontype"))); $frmAction->Show(); } @@ -1511,7 +1515,7 @@ $form->AddVar("resouceid",$resourceid); } - if($resource!=2) + if($resource!=3) { $form->AddRow(S_WIDTH, new CTextBox("width",$width,5)); $form->AddRow(S_HEIGHT, new CTextBox("height",$height,5)); @@ -1541,22 +1545,29 @@ { global $_REQUEST; - if(isset($_REQUEST["mediaid"])) + if(isset($_REQUEST["mediaid"]) && $_REQUEST["form"]!=1) { $media=get_media_by_mediaid($_REQUEST["mediaid"]); - $severity=$media["severity"]; - $sendto=$media["sendto"]; - $active=$media["active"]; - $mediatypeid=$media["mediatypeid"]; - $period=$media["period"]; + + $severity = $media["severity"]; + $sendto = $media["sendto"]; + $mediatypeid = $media["mediatypeid"]; + $active = $media["active"]; + $period = $media["period"]; + + if($severity & 1) $_REQUEST["0"]='yes'; + if($severity & 2) $_REQUEST["1"]='yes'; + if($severity & 4) $_REQUEST["2"]='yes'; + if($severity & 8) $_REQUEST["3"]='yes'; + if($severity & 16) $_REQUEST["4"]='yes'; + if($severity & 32) $_REQUEST["5"]='yes'; } else { - $sendto=""; - $severity=63; - $mediatypeid=-1; - $active=0; - $period="1-7,00:00-23:59"; + $sendto = get_request("sendto",""); + $mediatypeid = get_request("mediatypeid",0); + $active = get_request("active",0); + $period = get_request("period","1-7,00:00-23:59"); } $frmMedia = new CFormTable(S_NEW_MEDIA,"media.php"); @@ -1569,8 +1580,7 @@ } $cmbType = new CComboBox("mediatypeid",$mediatypeid); - $sql="select mediatypeid,description from media_type order by type"; - $types=DBselect($sql); + $types=DBselect("select mediatypeid,description from media_type order by type"); while($type=DBfetch($types)) { $cmbType->AddItem($type["mediatypeid"],$type["description"]); @@ -1581,12 +1591,13 @@ $frmMedia->AddRow(S_WHEN_ACTIVE,new CTextBox("period",$period,48)); $frm_row = array(); - array_push($frm_row, new CCheckBox(0, 1 & $severity, S_NOT_CLASSIFIED), BR); - array_push($frm_row, new CCheckBox(1, 2 & $severity, S_INFORMATION), BR); - array_push($frm_row, new CCheckBox(2, 4 & $severity, S_WARNING), BR); - array_push($frm_row, new CCheckBox(3, 8 & $severity, S_AVERAGE), BR); - array_push($frm_row, new CCheckBox(4, 16 & $severity, S_HIGH), BR); - array_push($frm_row, new CCheckBox(5, 32 & $severity, S_DISASTER), BR); + + array_push($frm_row, new CCheckBox("0", get_request("0", 'no'), S_NOT_CLASSIFIED), BR); + array_push($frm_row, new CCheckBox("1", get_request("1", 'no'), S_INFORMATION), BR); + array_push($frm_row, new CCheckBox("2", get_request("2", 'no'), S_WARNING), BR); + array_push($frm_row, new CCheckBox("3", get_request("3", 'no'), S_AVERAGE), BR); + array_push($frm_row, new CCheckBox("4", get_request("4", 'no'), S_HIGH), BR); + array_push($frm_row, new CCheckBox("5", get_request("5", 'no'), S_DISASTER), BR); $frmMedia->AddRow(S_USE_IF_SEVERITY,$frm_row); $cmbStat = new CComboBox("active",$active); @@ -1598,10 +1609,11 @@ if(isset($_REQUEST["mediaid"])) { $frmMedia->AddItemToBottomRow(SPACE); - $frmMedia->AddItemToBottomRow(new CButton("delete",S_DELETE,"return Confirm('".S_DELETE_SELECTED_MEDIA_Q."');")); + $frmMedia->AddItemToBottomRow(new CButtonDelete(S_DELETE_SELECTED_MEDIA_Q, + url_param("userid").url_param("mediaid"))); } $frmMedia->AddItemToBottomRow(SPACE); - $frmMedia->AddItemToBottomRow(new CButton("cancel",S_CANCEL)); + $frmMedia->AddItemToBottomRow(new CButtonCancel(url_param("userid"))); $frmMedia->Show(); } diff --git a/frontends/php/media.php b/frontends/php/media.php index f549e945..3997fba6 100644 --- a/frontends/php/media.php +++ b/frontends/php/media.php @@ -39,7 +39,7 @@ ?> - "; - $h2=$h2.""; - show_header2($h1, $h2, "
", "
"); + $form = new CForm("media.php"); + $form->AddVar("userid",$_REQUEST["userid"]); + $form->AddItem(new CButton("form",S_CREATE_MEDIA)); + show_header2(S_MEDIA_BIG, $form); ?> - setHeader(array(S_TYPE,S_SEND_TO,S_WHEN_ACTIVE,S_STATUS,S_ACTIONS)); - $col=0; + $result=DBselect("select m.mediaid,mt.description,m.sendto,m.active,m.period". + " from media m,media_type mt where m.mediatypeid=mt.mediatypeid". + " and m.userid=".$_REQUEST["userid"]." order by mt.type,m.sendto"); + while($row=DBfetch($result)) { if($row["active"]==0) { - $status="".S_ENABLED.""; + $status=new CLink(S_ENABLED, + "media.php?disable=1&mediaid=".$row["mediaid"].url_param("userid"), + "enabled"); } else { - $status="".S_DISABLED.""; + $status=new CLink(S_DISABLED, + "media.php?enable=1&mediaid=".$row["mediaid"].url_param("userid"), + "disabled"); } - $actions="".S_CHANGE.""; + $table->addRow(array( $row["description"], $row["sendto"], $row["period"], $status, - $actions + new CLink(S_CHANGE, + "media.php?form=0&mediaid=".$row["mediaid"]. + "&userid=".$_REQUEST["userid"] + ) )); } $table->show(); } - else - { - insert_media_form(); - } ?>