• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

mail_attachment.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00033 require_once "./include/inc.header.php";
00034 require_once "./include/inc.mail.php";
00035 require_once "classes/class.ilFormatMail.php";
00036 require_once "classes/class.ilFileDataMail.php";
00037 $lng->loadLanguageModule("mail");
00038 $lng->loadLanguageModule("forum");
00039 
00040 $mfile = new ilFileDataMail($_SESSION["AccountId"]);
00041 
00042 // GET SAVED DATA
00043 $umail = new ilFormatMail($_SESSION["AccountId"]);
00044 $mail_data = $umail->getSavedData();
00045 
00046 $_POST["filename"] = $_POST["filename"] ? $_POST["filename"] : array();
00047 
00048 $tpl->addBlockFile("CONTENT", "content", "tpl.mail_attachment.html");
00049 $tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00050 $tpl->setVariable("TXT_ATTACHMENT",$lng->txt("attachment"));
00051 infoPanel();
00052 
00053 // LOCATOR
00054 setLocator($_GET["mobj_id"],"mail_attachment.php", $_SESSION["AccountId"],"");
00055 
00056 if(isset($_POST["attachment"]["adopt"]))
00057 {
00058         $umail->saveAttachments($_POST["filename"]);
00059         header("location:mail_new.php?mobj_id=$_GET[mobj_id]&type=attach");
00060         exit();
00061 
00062 }
00063 if(isset($_POST["attachment"]["cancel"]))
00064 {
00065         header("location:mail_new.php?mobj_id=$_GET[mobj_id]&type=attach");
00066         exit;
00067 
00068 }
00069 if(isset($_POST["attachment"]["delete"]))
00070 {
00071         if(!$_POST["filename"])
00072         {
00073                 sendInfo($lng->txt("mail_select_one_file"));
00074                 $error_delete = true;
00075         }
00076         else
00077         {
00078                 sendInfo($lng->txt("mail_sure_delete_file"));
00079         }
00080 }
00081 // UPLOAD FILE
00082 if(isset($_POST["cmd"]["upload"]))
00083 {
00084         if($mfile->storeUploadedFile($_FILES['userfile']) == 1)
00085         {
00086                 sendInfo($lng->txt("mail_maxsize_attachment_error")." ".$mfile->getUploadLimit()." K".$lng->txt("mail_byte"));
00087         }
00088 }
00089 // CONFIRM CANCELED
00090 if(isset($_POST["cmd"]["cancel"]))
00091 {
00092         header("location:mail_attachment.php?mobj_id=$_GET[mobj_id]");
00093         exit;
00094 }
00095 // DELETE CONFIRMED
00096 if(isset($_POST["cmd"]["confirm"]))
00097 {
00098         if(!$_POST["filename"])
00099         {
00100                 sendInfo($lng->txt("mail_select_one_mail"));
00101         }
00102         else if($error = $mfile->unlinkFiles($_POST["filename"]))
00103         {
00104                 sendInfo($lng->txt("mail_error_delete_file")." ".$error);
00105         }
00106         else
00107         {
00108                 sendInfo($lng->txt("mail_files_deleted"));
00109         }
00110 }
00111 
00112 // BUTTONS
00113 include "./include/inc.mail_buttons.php";
00114 
00115 $tpl->setVariable("ACTION","mail_attachment.php?mobj_id=$_GET[mobj_id]");
00116 $tpl->setVariable("UPLOAD","mail_attachment.php?mobj_id=$_GET[mobj_id]");
00117 
00118 // BEGIN CONFIRM_DELETE
00119 if(isset($_POST["attachment"]["delete"]) and !$error_delete and !isset($_POST["cmd"]["confirm"]))
00120 {
00121         $tpl->setCurrentBlock("confirm_delete");
00122         $tpl->setVariable("BUTTON_CONFIRM",$lng->txt("confirm"));
00123         $tpl->setVariable("BUTTON_CANCEL",$lng->txt("cancel"));
00124         $tpl->parseCurrentBlock();
00125 }
00126 
00127 // SET STATIC VARIABLES ;-)
00128 $tpl->setVariable("TXT_ATTACHMENT",$lng->txt("attachment"));
00129 $tpl->setVariable("TXT_FILENAME",$lng->txt("mail_file_name"));
00130 $tpl->setVariable("TXT_FILESIZE",$lng->txt("mail_file_size"));
00131 $tpl->setVariable("TXT_CREATE_TIME",$lng->txt("forums_thread_create_date"));
00132 $tpl->setVariable("TXT_NEW_FILE",$lng->txt("mail_new_file"));
00133 
00134 // ACTIONS
00135 $tpl->setVariable("BUTTON_ATTACHMENT_ADOPT",$lng->txt("adopt"));
00136 $tpl->setVariable("BUTTON_ATTACHMENT_CANCEL",$lng->txt("cancel"));
00137 $tpl->setVariable("BUTTON_ATTACHMENT_DELETE",$lng->txt("delete"));
00138 
00139 // BUTTONS
00140 $tpl->setVariable("BUTTON_SUBMIT",$lng->txt("submit"));
00141 $tpl->setVariable("BUTTON_UPLOAD",$lng->txt("upload"));
00142 
00143 // BEGIN FILES
00144 if($files = $mfile->getUserFilesData())
00145 {
00146         $counter = 0;
00147         foreach($files as $file)
00148         {
00149                 $tpl->setCurrentBlock('files');
00150                 if(in_array($file["name"],$mail_data["attachments"]) ||
00151                    in_array($file["name"],$_POST["filename"]))
00152                 {
00153                         $tpl->setVariable("CHECKED",'checked');
00154                 }
00155                 $tpl->setVariable('CSSROW',++$counter%2 ? 'tblrow1' : 'tblrow2');
00156                 $tpl->setVariable('FILE_NAME',$file["name"]);
00157                 $tpl->setVariable("NAME",$file["name"]);
00158                 $tpl->setVariable("SIZE",$file["size"]);
00159                 $tpl->setVariable("CTIME",$file["ctime"]);
00160                 $tpl->parseCurrentBlock();
00161         }
00162 }
00163 else
00164 {
00165         $tpl->setCurrentBlock("no_content");
00166         $tpl->setVariable("TXT_ATTACHMENT_NO",$lng->txt("mail_no_attachments_found"));
00167         $tpl->parseCurrentBlock();
00168 }
00169 $tpl->show();
00170 ?>

Generated on Fri Dec 13 2013 10:18:30 for ILIAS Release_3_5_x_branch .rev 46805 by  doxygen 1.7.1