connect(); if( !isset( $_GET['id'] ) ) { //The model doesn't exists exit; } //Load the notif.xml $notif_conf_path = "xml/notif.xml"; $notif_conf = new DomDocument(); $notif_conf->preserveWhiteSpace = false; $notif_conf->formatOutput = TRUE; $notif_conf->load($notif_conf_path); $xp_notif_conf = new domxpath($notif_conf); //Direct Notfication if( is_numeric($_GET['id']) ) { foreach($xp_notif_conf->query("/ROOT/NOTIFICATION[ID='".$_GET['id']."']/*") as $nc) { $this_notif[$nc->nodeName] = $nc->nodeValue; } } //Basket Notification else { foreach($xp_notif_conf->query("/ROOT/BASKET/*") as $nc) { $this_notif[$nc->nodeName] = $nc->nodeValue; } //Load the basket label $db->query("SELECT BASKET_NAME FROM baskets WHERE BASKET_ID = '".$_GET['id']."'"); $this_notif['LABEL'] = $db->fetch_object()->BASKET_NAME; //Create the new notification if( $xp_notif_conf->query("/ROOT/NOTIFICATION[ID='".$_GET['id']."']")->length != 1 && !empty($this_notif['LABEL']) ) { $new_notif = $notif_conf->createElement("NOTIFICATION"); $new_notif->appendChild($notif_conf->createElement("ID",$_GET['id'])); $new_notif->appendChild($notif_conf->createElement("SUBJECT")); $notif_conf->getElementsByTagName("ROOT")->item(0)->appendChild($new_notif); } //Load the notification foreach($xp_notif_conf->query("/ROOT/NOTIFICATION[ID='".$_GET['id']."']/*") as $nc) { $this_notif[$nc->nodeName] = $nc->nodeValue; } foreach($xp_notif_conf->query("/ROOT/BASKETS/*") as $nc) { $this_notif[$nc->nodeName] = $nc->nodeValue; } } //Load the HTML file if( file_exists( $xp_notif_conf->query("/ROOT/MODEL_RELATIVE_DIR")->item(0)->nodeValue."/".$_GET['id'].".html" ) ) { $html_content = file_get_contents($xp_notif_conf->query("/ROOT/MODEL_RELATIVE_DIR")->item(0)->nodeValue."/".$_GET['id'].".html"); } $select_sql = "SELECT "; //Load the maarch option field list from the basket sql select if( is_numeric($_GET['id']) ) { foreach( $xp_notif_conf->query("/ROOT/NOTIFICATION[ID='".$_GET['id']."']/SELECT") as $select ) { $alias = trim($xp_notif_conf->query("ALIAS",$select)->item(0)->nodeValue); if( $alias != "") { if( preg_match("/^'.*'$/",$alias) ) $select_sql .= $alias; else $select_sql .= "'".$alias."'"; $select_sql .= ","; } unset($alias); } } else { foreach( $xp_notif_conf->query("/ROOT/BASKETS/SELECT") as $select ) { $alias = trim($xp_notif_conf->query("ALIAS",$select)->item(0)->nodeValue); if( $alias != "") { if( preg_match("/^'.*'$/",$alias) ) $select_sql .= $alias; else $select_sql .= "'".$alias."'"; $select_sql .= ","; } unset($alias); } } $select_sql = substr($select_sql,0,-1); $db->query($select_sql); $fields_array = array(); $fields_array = $db->fetch_row(); foreach( $fields_array as $fa) if( !empty($fa) ) { $maarch_options .= ""; } if( isset($maarch_options) ) { $maarch_options = "". "". ""; } if( isset($_POST['action']) ) { if( $_POST['action'] == _VALIDATE ) { //Save XML $xp_notif_conf->query("/ROOT/NOTIFICATION[ID='".$_GET['id']."']/SUBJECT")->item(0)->nodeValue = stripslashes($_POST['object']); $notif_conf->save($notif_conf_path); //Save HTML file_put_contents($xp_notif_conf->query("/ROOT/MODEL_RELATIVE_DIR")->item(0)->nodeValue."/".$_GET['id'].".html",stripslashes($_POST['model_content'])); } else if( $_POST['action'] == _CANCEL ) { //Nothing to do } else { //Invalid action } header("Location: index.php?page=notif"); } else { ?>