Location: PHPKode > projects > ADbNewsSender > ADbNewsSender 2.1.0/protected/admin/nl/drafts.php.inc
<?php
//Copyright (c) Florian Grannemann
//Last change in version: 2.1 Alpha 5
/*
    ******************************************************************************
    ADbNewsSender 2

    Copyright (C) 2010 Florian Grannemann (hide@address.com)
    Website: http://adbnewssender.sf.net



    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License			
    along with this program.  If not, see http://www.gnu.org/licenses/
    ******************************************************************************
*/
include "$path_to_languagefolder/lang_admin_drafts.php.inc";

//Do not edit anything unless you realy REALY know what you are doing!
if($MySessionHandler->getNLID()!=0 && $MyCFG->NL_exists($MySessionHandler->getNLID()))
{
    //mudule variables:
    $NLID=$MySessionHandler->getNLID();
    //Request varaiables:
    //DraftType
    //DraftBody
    //DraftSubject
    //CurrentDraft
    
    $curmodul=$MySessionHandler->getCurrentModule();
    //create a ADBNS_Drafts object:
    $MyDrafts=new ADBNS_Drafts($NLID, $MyDB); 
   
    if(!$MyRequestHandler->getNLModuleKeyValue("DraftsOption") || $MyRequestHandler->getNLModuleKeyValue("DraftsOption")=="save"|| $MyRequestHandler->getNLModuleKeyValue("DraftsOption")=="save_new" )
    {
	
	
	if($MyRequestHandler->getNLModuleKeyValue("DraftsOption")=="save")
	{
	    //save changes
	    if($MyDrafts->update_draft(intval($MySessionHandler->getNLModuleKeyValue("CurrentDraft")),$MySessionHandler->getNLModuleKeyValue("body"),$MySessionHandler->getNLModuleKeyValue("subject"),$MySessionHandler->getNLModuleKeyValue("type")))
	    {
		print "<b>".preg_replace("/<-DraftID->/",intval($MySessionHandler->getNLModuleKeyValue("CurrentDraft")),$MSGUpdateSuccess)."</b><br>"; 
	    }
	    else
	    {
		print "<b>".preg_replace("/<-DraftID->/",intval($MySessionHandler->getNLModuleKeyValue("CurrentDraft")),$MSGUpdateFailed)."</b><br>";
	    }

	    $MySessionHandler->setNLModuleKey("CurrentDraft","");
	    $MySessionHandler->setNLModuleKey("type","");
	    $MySessionHandler->setNLModuleKey("body","");
	    $MySessionHandler->setNLModuleKey("subject","");

	}
	if($MyRequestHandler->getNLModuleKeyValue("DraftsOption")=="save_new")
	{
		//save as new  draft
	    $result=$MyDrafts->add_draft($MySessionHandler->getNLModuleKeyValue("body"),$MySessionHandler->getNLModuleKeyValue("subject"),$MySessionHandler->getNLModuleKeyValue("type"));
	    print "$MSG_Draft_saved <br>";
	   $MySessionHandler->setNLModuleKey("CurrentDraft","");
	   $MySessionHandler->setNLModuleKey("type","");
	   $MySessionHandler->setNLModuleKey("body","");
	   $MySessionHandler->setNLModuleKey("subject","");
	}

	$copyDraftsEnabled=false;
	$nlList=array();
	$nlList=$MyCFG->get_all_newsletters();
	if(count($nlList) >1){
	    $copyDraftsEnabled=true;
	}
	 //Session keys:
	 //ShowDraftsDirection //ASC or DESC
	 //ShowDraftsOrderby //field name (lower case)
	 //ShowDraftslastnext //last or next
	 //ShowDraftsperpage //number 1-200
	 //ShowDraftsStartat
	 //ShowDraftsEndat

	 //GET/POST parameter names:
	 //ShowDraftsDirection
	 //ShowDraftsOrderby
	 //ShowDraftslastnext
	 //ShowDraftsperpage
	 //ShowDraftsStartat
	 //ShowDraftsEndat
	//DraftsAction
	//DraftsSubmitList	
	//DraftsSubmitListCount

	if($MyRequestHandler->getNLModuleKeyValue("DraftsAction")=="delete")
	{
	   $deletelist=$MyRequestHandler->getNLModuleKeyValue("DraftsSubmitList");
	   $i=0;
	   while($i < intval($MyRequestHandler->getNLModuleKeyValue("DraftsSubmitListCount")))
	   {
		if(intval($deletelist[$i])>0)
		{
			if($MyDrafts->delete_draft($deletelist[$i]))
			{
			    print preg_replace("/<-ID->/",$deletelist[$i],$MSG_Draft_deleted)."<br>";
			}
		
		}
		$i++;
	    
	   }
	   print "<br><br>"; 
	   $MySessionHandler->setNLModuleKey("ShowDraftsperpage",15);
	   $MySessionHandler->setNLModuleKey("ShowDraftsStartat",0);
	}
	//Copy draft to nl:
	if($MyRequestHandler->getNLModuleKeyValue("DraftsAction")=="copyNL"){
	   $copylist=$MyRequestHandler->getNLModuleKeyValue("DraftsSubmitList");
	   $i=0;
	   if($MyCFG->NL_exists($MyRequestHandler->getNLModuleKeyValue("CopyToNL"))){
		    $NLName=$MyCFG->get_NL_name($MyRequestHandler->getNLModuleKeyValue("CopyToNL"));
		    $TempDraft=new ADBNS_Drafts($MyRequestHandler->getNLModuleKeyValue("CopyToNL"),$MyDB);
		    while($i < intval($MyRequestHandler->getNLModuleKeyValue("DraftsSubmitListCount")))
		    {
			$newDraftID=0;    
			if(intval($copylist[$i])>0)
			{
			    $draftdata=$MyDrafts->get_draft_data($copylist[$i]);
			    if(count($draftdata)>0){
				$newDraftID=$TempDraft->add_draft(html_entity_decode($draftdata["message"]),html_entity_decode($draftdata["subject"]),$draftdata["type"]);				
			    }
			    if($newDraftID>0){
				 //copied the draft successful:
				 $tempmessage=preg_replace("/<-ID->/",$copylist[$i],$MSG_Draft_copied);
				 print preg_replace("/<-NLName->/",$NLName,$tempmessage)."<br>";		    
			    }
			    else{
				   print preg_replace("/<-ID->/",$copylist[$i],$MSG_Draft_copyfailed1)."<br>";    
			    }
			}
			
		    $i++;  
		}
		
	    }
	    else{
		    //maybe the selected newsletter does not exist...
		    if(intval($MyRequestHandler->getNLModuleKeyValue("CopyToNL"))>0){
			print $MSG_Draft_copyfailed2;
		    }
		    else{
			//...or no newsletter has been selected.
			print $MSG_Draft_copyfailed3;
		    }
	    }
	    print "<br><br>"; 

	}

	
	print "<b><a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("DraftsOption")."=edit&".$MyRequestHandler->getNLModuleKeyName("DraftID")."=new\">$TXT_ADD_NewDraft</a></b><br><br>";
	//show drafts in a table, if at least one draft exists:

	if($MyDrafts->number_of_drafts() >0){
	    //setting defaults:
	    if(!$MySessionHandler->getNLModuleKeyValue("ShowDraftsOrderby"))
	    {
		$MySessionHandler->setNLModuleKey("ShowDraftsOrderby","id");

	    }
	    if(!$MySessionHandler->getNLModuleKeyValue("ShowDraftsStartat"))
	    {
		$MySessionHandler->setNLModuleKey("ShowDraftsStartat",0);

	    }
	    if(!$MySessionHandler->getNLModuleKeyValue("ShowDraftslastnext"))
	    {
		$MySessionHandler->setNLModuleKey("ShowDraftslastnext","next");

	    }
	    if(!$MySessionHandler->getNLModuleKeyValue("ShowDraftsperpage"))
	    {
		$MySessionHandler->setNLModuleKey("ShowDraftsperpage",15);

	    }
	    if(!$MySessionHandler->getNLModuleKeyValue("ShowDraftsEndat"))
	    {
		$MySessionHandler->setNLModuleKey("ShowDraftsEndat",$MySessionHandler->getNLModuleKeyValue("ShowDraftsperpage"));

	    }
	    
	     if(!$MySessionHandler->getNLModuleKeyValue("ShowDraftsDirection"))
	    {
		$MySessionHandler->setNLModuleKey("ShowDraftsDirection","ASC");

	    }
	      //looking for changes:
	    
	    if($MyRequestHandler->issetNLModuleKey("ShowDraftsDirection"))
	    {
		
		$MySessionHandler->setNLModuleKey("ShowDraftsDirection",$MyRequestHandler->getNLModuleKeyValue("ShowDraftsDirection"));
		$MySessionHandler->setNLModuleKey("ShowDraftsStartat",0);
		$MySessionHandler->setNLModuleKey("ShowDraftsEndat",$MySessionHandler->getNLModuleKeyValue("ShowDraftsperpage"));

	    }
	    if($MyRequestHandler->issetNLModuleKey("ShowDraftsOrderby"))
	    {
		$MySessionHandler->setNLModuleKey("ShowDraftsOrderby",$MyRequestHandler->getNLModuleKeyValue("ShowDraftsOrderby"));
		$MySessionHandler->setNLModuleKey("ShowDraftsStartat",0);
		$MySessionHandler->setNLModuleKey("ShowDraftsEndat",$MySessionHandler->getNLModuleKeyValue("ShowDraftsperpage"));
	    }
	    if($MyRequestHandler->issetNLModuleKey("ShowDraftsStartat"))
	    {
		$MySessionHandler->setNLModuleKey("ShowDraftsStartat",$MyRequestHandler->getNLModuleKeyValue("ShowDraftsStartat"));
	
		
	    }
	     if($MyRequestHandler->issetNLModuleKey("ShowDraftsEndat"))
	    {
		$MySessionHandler->setNLModuleKey("ShowDraftsEndat",$MyRequestHandler->getNLModuleKeyValue("ShowDraftsEndat"));
	
		
	    }
	   
	    if($MyRequestHandler->issetNLModuleKey("ShowDraftsperpage"))
	    {
		$MySessionHandler->setNLModuleKey("ShowDraftsperpage",intval($MyRequestHandler->getNLModuleKeyValue("ShowDraftsperpage")));
		$MySessionHandler->setNLModuleKey("ShowDraftsStartat",0);
		$MySessionHandler->setNLModuleKey("ShowDraftsEndat",$MySessionHandler->getNLModuleKeyValue("ShowDraftsperpage"));
	    }
       
	    //fetching drafts:
	    $drafts_array=array();
	    $offset=$MySessionHandler->getNLModuleKeyValue("ShowDraftsEndat") - $MySessionHandler->getNLModuleKeyValue("ShowDraftsStartat");
	    $drafts_array=$MyDrafts->get_drafts($MySessionHandler->getNLModuleKeyValue("ShowDraftsStartat"),$offset,$MySessionHandler->getNLModuleKeyValue("ShowDraftsOrderby"),$MySessionHandler->getNLModuleKeyValue("ShowDraftsDirection"));
	
	    //displaying table:
	   
	    print "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"post\">$ShowDrafts_order_Direction: ";
	
	    print "<select name=\"".$MyRequestHandler->getNLModuleKeyName("ShowDraftsDirection")."\">";
	    print "<option value=\"ASC\"";
	    if($MySessionHandler->getNLModuleKeyValue("ShowDraftsDirection")== "ASC")
	    {
		print " selected ";
	    }
	    print ">$ShowDrafts_order_Asc</option>";

	     print "<option value=\"DESC\"";
	    if($MySessionHandler->getNLModuleKeyValue("ShowDraftsDirection")== "DESC")
	    {
		print " selected ";
	    }
	    print ">$ShowDrafts_order_Desc</option></select>";

	    print "$ShowDrafts_showperpage: ";
	    print "<select name=\"".$MyRequestHandler->getNLModuleKeyName("ShowDraftsperpage")."\">";
	    
	    $i=1;
	    while($i <= 200)
	    {
		print "<option value=\"$i\"";
		if ($i ==$MySessionHandler->getNLModuleKeyValue("ShowDraftsperpage"))
		{
		    print " selected ";
		}
		print ">$i</option>";
		
		$i++;
	    }
	    print "</select><input type=\"submit\" value=\"$ShowDrafts_change_options\"></form>";
	    print "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"post\">";
	    print "<table border=1 >";
	    print "<tr><td></td>";
	    
	    //Table column ID:
	    print "<td>";
	    print "<a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowDraftsOrderby")."=id\" title=\"$ShowDrafts_tooltext_orderby\">";
	    if($MySessionHandler->getNLModuleKeyValue("ShowDraftsOrderby")=="id")
	    {
		print "<b>$ShowDrafts_table_id</b>";
	    }
	    else
	    {
		print "$ShowDrafts_table_id";
	    }
	    print "</a></td>";
	   //Table column subject:
	   print "<td>";
	   print "<a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowDraftsOrderby")."=subject\" title=\"$ShowDrafts_tooltext_orderby\">";
	   if($MySessionHandler->getNLModuleKeyValue("ShowDraftsOrderby")=="subject")
	   {
		print "<b>$ShowDrafts_table_subject</b>";
	   }
	   else
	   {
		print "$ShowDrafts_table_subject";
	   }
	   print "</a></td>";
	   
	   //Table column type:
	   print "<td>";
	   print "<a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowDraftsOrderby")."=type\" title=\"$ShowDrafts_tooltext_orderby\">";
	   if($MySessionHandler->getNLModuleKeyValue("ShowDraftsOrderby")=="type")
	   {
		print "<b>$ShowDrafts_table_type</b>";
	   }
	   else
	   {
		print "$ShowDrafts_table_type";
	   }
	   print "</a></td>"; 

	   print "<td>";
	   print "<a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowDraftsOrderby")."=date\" title=\"$ShowDrafts_tooltext_orderby\">";
	   if($MySessionHandler->getNLModuleKeyValue("ShowDraftsOrderby")=="date")
	   {
		print "<b>$ShowDrafts_table_date</b>";
	   }
	   else
	   {
		print "$ShowDrafts_table_date";
	   }
	   print "</a></td>"; 
	   print "<td>$ShowDrafts_table_options</td></tr>";
	   
	   $i=0;
	    
	   $timezone=$MyCFG->get_timezone();
	   while ($i < count($drafts_array))
	   {

		if($drafts_array[$i]["id"])
		{
		    print "<tr><td>";
		    print "<input type=\"checkbox\" name=\"".$MyRequestHandler->getNLModuleKeyName("DraftsSubmitList")."[$i]\" value=\"".$drafts_array[$i]["id"]."\"></td>";
		    print "</td>";
		    print "<td>".$drafts_array[$i]["id"]."</td>";
		    print "<td>".html_entity_decode($drafts_array[$i]["subject"])."</td>";
		    
		    if($drafts_array[$i]["type"]=="html")
		    {
			print "<td>".$ShowDraftsTable_TypeHTML."</td>";
		    }
		    else
		    {
			print "<td>".$ShowDraftsTable_TypeText."</td>";
		    }
		    print "<td>".date("$dateformat, $timeformat",$drafts_array[$i]["date"])." ($timezone)</td>";
		
		    //draft options:
		    print "<td>";
		    $MyRequestHandler->setCurrentModuleNumber(0);
		    print "<a href=\"".$_SERVER["PHP_SELF"]."?SelectNL=$NLID&modul=nl|0&".$MyRequestHandler->getNLModuleKeyName("UseDraft")."=".$drafts_array[$i]["id"]."&".$MyRequestHandler->getNLModuleKeyName("type")."=".$drafts_array[$i]["type"]."\" title=\"$ShowDrafts_Drafts_option_Tooltip_SendDraft\" >$ShowDrafts_Drafts_option_SendDraft</a> <br>";
		    $MyRequestHandler->setCurrentModuleNumber($MySessionHandler->getCurrentModuleNumber());
		    print "<a href=\"".$_SERVER["PHP_SELF"]."?SelectNL=$NLID&".$MyRequestHandler->getNLModuleKeyName("DraftsOption")."=edit&".$MyRequestHandler->getNLModuleKeyName("DraftID")."=".$drafts_array[$i]["id"]."&".$MyRequestHandler->getNLModuleKeyName("DraftType")."=".$drafts_array[$i]["type"]."\" title=\"$ShowDrafts_Drafts_option_Tooltip_EditDraft\">$ShowDrafts_Drafts_option_EditDraft</a><br>";
		    print "<a href=\"ExportDraft.php?NLID=$NLID&DraftID=".$drafts_array[$i]["id"]."&DraftType=".$drafts_array[$i]["type"]."\" title=\"$ShowDrafts_Drafts_option_Tooltip_ExportDraft\" target=\"_blank\">$ShowDrafts_Drafts_option_ExportDraft</a><br>";
		    print "</td>";
		    print "</tr>";
		   
		}

		$i++;
	   }
	    
	 print "</table>";
	 
	 print "<input type=\"hidden\" name=\"".$MyRequestHandler->getNLModuleKeyName("DraftsSubmitListCount")."\" value=\"$i\">";
	 print "<input type=\"hidden\" name=\"".$MyRequestHandler->getNLModuleKeyName("ShowDraftsStartat")."\" value=\"0\">";
	 print "<input type=\"hidden\" name=\"".$MyRequestHandler->getNLModuleKeyName("ShowDraftsEndat")."\" value=\"15\">";
	 print $ShowDrafts_action_for_selected." <select name=\"".$MyRequestHandler->getNLModuleKeyName("DraftsAction")."\" onChange=\"onDraftsActionchange()\">";
	 print "<option value=\"\">".$ShowDrafts_PleaseSelect."</option>";
	 print "<option value=\"delete\"";
	 if(!$copyDraftsEnabled){
		print " selected";
	 }
	 print ">".$ShowDrafts_DeleteDrafts."</option>";
	 if($copyDraftsEnabled){
		print "<option value=\"copyNL\">".$ShowDrafts_CopyToNL."</option>";
	 }
	 print "</select>";
	 print "<select name=\"".$MyRequestHandler->getNLModuleKeyName("CopyToNL")."\" style=\"visibility:hidden;width:0px\">";
	 print "<option value=\"\">".$ShowDrafts_PleaseSelectNL."</option>";

	 $i=0;
	 while($i < count($nlList)){

	    if($nlList[$i] != $NLID){
		 print "<option value=\"".$nlList[$i]."\">".$MyCFG->get_NL_name($nlList[$i])."</option>";
	    }
	    $i++;
	 }
	 print "</select>";
	 print "<input type=\"submit\" value=\"".$ShowDrafts_Submit."\"></form>";
	
	  $NumberOfEntries=$MyDrafts->number_of_drafts();

	   
	    //next/last
	    //show last:
	    $last_entries=0;
	   if($MySessionHandler->getNLModuleKeyValue("ShowDraftsStartat") >0)
	   {
		if($MySessionHandler->getNLModuleKeyValue("ShowDraftsStartat")-$MySessionHandler->getNLModuleKeyValue("ShowDraftsperpage") >=0)
		{
		    $last_entries=$MySessionHandler->getNLModuleKeyValue("ShowDraftsperpage");

		}
		else
		{
		    $last_entries=$MySessionHandler->getNLModuleKeyValue("ShowDraftsStartat");
		}
		
		print "<a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowDraftsStartat")."=";
		print ($MySessionHandler->getNLModuleKeyValue("ShowDraftsStartat")-$last_entries)."&".$MyRequestHandler->getNLModuleKeyName("ShowDraftsEndat")."=";
		print ($MySessionHandler->getNLModuleKeyValue("ShowDraftsStartat"))."\">&lt;- $ShowDrafts_showlast  $last_entries</a>"; 
	   }
	   
	 //show next:
	   $next_entries=0;
	   if($MySessionHandler->getNLModuleKeyValue("ShowDraftsEndat") < ($NumberOfEntries) )
	    {
		if($MySessionHandler->getNLModuleKeyValue("ShowDraftsEndat")+$MySessionHandler->getNLModuleKeyValue("ShowDraftsperpage") <=($NumberOfEntries-1))
		{
		    $next_entries=$MySessionHandler->getNLModuleKeyValue("ShowDraftsperpage");
		}
		else
		{
		    $next_entries=($NumberOfEntries)-$MySessionHandler->getNLModuleKeyValue("ShowDraftsEndat");

		}
		if ($last_entries >0)
		{
		    print " | ";
		}
		
		print "<a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowDraftsStartat")."=";
		print ($MySessionHandler->getNLModuleKeyValue("ShowDraftsEndat"))."&".$MyRequestHandler->getNLModuleKeyName("ShowDraftsEndat")."=";
		print ($MySessionHandler->getNLModuleKeyValue("ShowDraftsEndat")+$next_entries)."\">$ShowDrafts_shownext  $next_entries -&gt;</a>"; 
	    }
	   
	  
	
	}
	else{	//if no draft exists:
		print $TXT_No_Draft_Available."<br>";
	}

    }
    if($MyRequestHandler->getNLModuleKeyValue("DraftsOption")=="edit")
    {
	//add or edit a draft:
	print "<h3>$TXT_ADD_EDIT_draft</h3>";
	//if a draft has been uploaded:
	if($_FILES["uploadfile".$NLID]['tmp_name'])
	{
	  //  print $_FILES["uploadfile".$NLID]["error"];
	    if(!$_FILES["uploadfile".$NLID]["error"])
	    {
		$text=file($_FILES["uploadfile".$NLID]["tmp_name"]);
		$text=implode("\n",$text);
		$MySessionHandler->setNLModuleKey("body",$text);
		$MySessionHandler->setNLModuleKey("subject",$MyRequestHandler->getNLModuleKeyValue("DraftSubject"));
		if($_FILES["uploadfile".$NLID]["type"]=="text/html")
		{
		    $MySessionHandler->setNLModuleKey("type","html");
		}
		else
		{
		    $MySessionHandler->setNLModuleKey("type","text");
		}
		
	    }
	    else
	    {
		print "<b>$ErorUploadfailed</b>";
	    }

	    @unlink($_FILES["uploadfile".$NLID]["tmp_name"]);
	    print "<br><br>";
	}	
	if($MyRequestHandler->getNLModuleKeyValue("DraftID")=="new")
	{
		$MySessionHandler->setNLModuleKey("CurrentDraft","new");
		$MySessionHandler->setNLModuleKey("type","html");
		$MySessionHandler->setNLModuleKey("body","");
		$MySessionHandler->setNLModuleKey("subject","");
	}
	else
	{
	    if(intval($MyRequestHandler->getNLModuleKeyValue("DraftID"))>0)
	    {
		//load draft
		$DraftARR=array();
		$DraftARR=$MyDrafts->get_draft_data(intval($MyRequestHandler->getNLModuleKeyValue("DraftID")));
		if(count ($DraftARR) <1)
		{
		    print "<b>$ERR_Draft_does_not_exist</b><br>";
		    $MySessionHandler->setNLModuleKey("CurrentDraft","new");
		    $MySessionHandler->setNLModuleKey("type","html");
		    $MySessionHandler->setNLModuleKey("body","");
		    $MySessionHandler->setNLModuleKey("subject","");
		}
		else
		{
		   
		    $MySessionHandler->setNLModuleKey("type",$DraftARR["type"]);
		    $MySessionHandler->setNLModuleKey("CurrentDraft",intval($MyRequestHandler->getNLModuleKeyValue("DraftID")));
		    $MySessionHandler->setNLModuleKey("body",html_entity_decode($DraftARR["message"]));
		    $MySessionHandler->setNLModuleKey("subject",html_entity_decode($DraftARR["subject"]));
		}
	    }
	}
	
	
	print "<a href=\"".$_SERVER["PHP_SELF"]."?SelectNL=$NLID&".$MyRequestHandler->getNLModuleKeyName("DraftsOption")."=upload&modul=".$curmodul."\">";
	print $TXT_Upload_new."</a><br><br>";
	

	print $TXT_EnterDraft."<br>";
	if($MyNL->get_NLconfig_setting("Archive_enabled")=="yes")
	{
	    print $TXT_ArchiveEntryURLInfo."<br>";
	}
	print "<form name=\"EditDraft\" action=\"".$_SERVER["PHP_SELF"]."\" method=\"post\">";
	print "<p>";
	print "$TXT_NL_type <select name=\"".$MyRequestHandler->getNLModuleKeyName("DraftType")."\""; 

	if($MyCFG->get_config_value("EnableTinyMCE")=="yes")
	{
	    print "onChange=\"switchEditor()\"";
	}
	print ">";
	print "<option value=\"text\""; if( $MySessionHandler->getNLModuleKeyValue("type") !="html"){print "selected";} print ">$TXT_type_text</option>";
	print "<option value=\"html\""; if( $MySessionHandler->getNLModuleKeyValue("type") =="html"){print "selected";}  print ">$TXT_type_html</option>";
	print "</select><br><br>";
	print "$TXT_Subject <input type=\"Text\" name=\"".$MyRequestHandler->getNLModuleKeyName("DraftSubject")."\" value=\"".$MySessionHandler->getNLModuleKeyValue("subject")."\" size=\"35\"> <br><br>";
        print "$TXT_Mailtext<br><textarea name=\"".$MyRequestHandler->getNLModuleKeyName("DraftBody")."\" cols=\"70\" rows=\"18\" >".stripslashes(htmlentities($MySessionHandler->getNLModuleKeyValue("body")))."</textarea> ";
        print "<input type=hidden name=\"".$MyRequestHandler->getNLModuleKeyName("DraftsOption")."\" value=\"preview\"><input type=hidden name=modul value=".$curmodul."\">";
	print "<input type=hidden name=\"SelectNL\" value=\"$NLID\"><br> <input type=\"submit\" value=\"$TXT_EnterDraft_SubmitButton\"></form>";
        print "</p>"; 
	print "<br><br><a href=\"".$_SERVER["PHP_SELF"]."?SelectNL=$NLID&modul=$curmodul\">$TXT_Back_to_draftsMenu</a><br>";

    }
    if($MyRequestHandler->getNLModuleKeyValue("DraftsOption")=="upload")
    {
	print "<h3>$TXT_Drafts_uploadFile_title</h3>
		<form action=\"".$_SERVER['PHP_SELF']."\" enctype=\"multipart/form-data\" method=\"post\">
		$TXT_Subject <input type=\"text\" name=\"".$MyRequestHandler->getNLModuleKeyName("DraftSubject")."\" value=\"".$MySessionHandler->getNLModuleKeyValue("subject")."\"><br>
		$TXT_File <input name=\"uploadfile".$NLID."\" type=\"file\"><br>
		<input type=\"hidden\" name=\"SelectNL\" value=\"$NLID\"><br>
		<input type=hidden name=\"modul\" value=\"".$curmodul."\">
		<input type=hidden name=\"".$MyRequestHandler->getNLModuleKeyName("DraftsOption")."\" value=\"edit\">
		<input name=\"Upload\" type=\"submit\" value=\"$MSG_Upload\">
		</form><br><br>
		<a href=\"".$_SERVER['PHP_SELF']."?modul=".$curmodul."&SelectNL=$NLID&".$MyRequestHandler->getNLModuleKeyName("DraftsOption")."=edit\">$MSG_Abort_Upload</a>
		";

    }
   
    if($MyRequestHandler->getNLModuleKeyValue("DraftsOption")=="preview")
    {
	$MySessionHandler->setNLModuleKey("body",$MyRequestHandler->getNLModuleKeyValue("DraftBody"));
	$MySessionHandler->setNLModuleKey("subject",$MyRequestHandler->getNLModuleKeyValue("DraftSubject"));
	$MySessionHandler->setNLModuleKey("type",$MyRequestHandler->getNLModuleKeyValue("DraftType"));

	
	if($MySessionHandler->getNLModuleKeyValue("type")=="html")
	{       
		
		
	    print "<b>".$TXT_Subject."</b> <input type =text value=\"".$MySessionHandler->getNLModuleKeyValue("subject")."\" size=50 readonly></font><br>";
		

	    print "<iframe src='previewNL.php?what=draft' framespacing='0' frameborder='1' WIDTH=100% height=500 scrolling='yes'></iframe>";


	    print "<br><p><font color=\"black\"><form action=".$_SERVER["PHP_SELF"]." method=post>";
	    
	    print "<input type=\"hidden\" name=\"SelectNL\" value=\"$NLID\"><input type=hidden name=modul value=".$curmodul."\">";	
            print $TXT_previewDraftSelect." <select  name=\"".$MyRequestHandler->getNLModuleKeyName("DraftsOption")."\" >";
	    print "<option value=\"edit\" selected>".stripslashes($TXT_DraftsOption_Edit)."</option>";
	    if($MySessionHandler->getNLModuleKeyValue("CurrentDraft")!="new")
	    {
		print "<option value=\"save\">".stripslashes($TXT_DraftsOption_save)."</option>";
	    }
	    print "<option value=\"save_new\">".stripslashes($TXT_DraftsOption_savenew)."</option>";
	    print "<option value=\"\">".stripslashes($TXT_DraftsOption_draftsMenu)."</option>";
	    print "</select> <input type=submit value=\"OK\"></form></font></p>";
		
	}
	else
	{	
		
		print "<h2>$TXT_previewDraft_Title</h2>";
		print "<p><b>".$TXT_Subject."</b> <input type=text size=35 value=\"".$MySessionHandler->getNLModuleKeyValue("subject")."\" readonly>";

		print "<br><br><b>".$TXT_Mailtext."</b><br>";
		
		if($MyNL->get_NLconfig_setting("Archive_enabled")=="yes")
		{
		    print "<textarea cols=\"65\" rows=\"12\" readonly>";
		    print htmlentities(preg_replace("/\[ArchiveEntryURL\]/",$TXT_RepArchiveURL,$MySessionHandler->getNLModuleKeyValue("body")));
		    print "</textarea>";
		}
		else
		{
		    print "<textarea cols=\"65\" rows=\"12\" readonly>";
		    print htmlentities($MySessionHandler->getNLModuleKeyValue("body"));
		    print "</textarea>";
		}
			    
        	
                print "<br><br><form action=".$_SERVER["PHP_SELF"]." method=post>";
		
		
                print "<input type=\"hidden\" name=\"SelectNL\" value=\"$NLID\"><input type=hidden name=modul value=".$curmodul."\">";	
		print $TXT_previewDraftSelect." <select  name=\"".$MyRequestHandler->getNLModuleKeyName("DraftsOption")."\" >";
		print "<option value=\"edit\" selected>".stripslashes($TXT_DraftsOption_Edit)."</option>";
		if($MySessionHandler->getNLModuleKeyValue("CurrentDraft")!="new")
		{
		    print "<option value=\"save\">".stripslashes($TXT_DraftsOption_save)."</option>";
		}
		print "<option value=\"save_new\">".stripslashes($TXT_DraftsOption_savenew)."</option>";
		 print "<option value=\"\">".stripslashes($TXT_DraftsOption_draftsMenu)."</option>";
		print "</select> <input type=submit value=\"OK\"></form></font></p>";
	
		
	}
	
    }

}
else
{
      print $ErrorNLdoesnotExist;
} 
?>
Return current item: ADbNewsSender