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

classes/class.ilObjMailGUI.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 
00038 require_once "class.ilObjectGUI.php";
00039 
00040 class ilObjMailGUI extends ilObjectGUI
00041 {
00046         function ilObjMailGUI($a_data,$a_id,$a_call_by_reference)
00047         {
00048                 $this->type = "mail";
00049                 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, false);
00050         }
00051 
00052         function viewObject()
00053         {
00054 #               parent::editObject();
00055                 
00056                 $this->lng->loadLanguageModule("mail");
00057 
00058                 $this->tpl->addBlockFile("SYSTEMSETTINGS", "systemsettings", "tpl.mail_basicdata.html");
00059                 $this->tpl->setCurrentBlock("systemsettings");
00060 
00061                 $settings = $this->ilias->getAllSettings();
00062 
00063                 if (isset($_POST["save_settings"]))  // formular sent
00064                 {
00065                         //init checking var
00066                         $form_valid = true;
00067                         
00068                         // put any checks here!!!
00069 
00070                         if (!$form_valid)       //required fields not satisfied. Set formular to already fill in values
00071                         {
00072                                 // mail server
00073                                 $settings["mail_server"] = $_POST["mail_server"];
00074                                 $settings["mail_port"] = $_POST["mail_port"];
00075 
00076                                 // internal mail
00077 #                               $settings["mail_intern_enable"] = $_POST["mail_intern_enable"];
00078                                 $settings["mail_maxsize_mail"] = $_POST["mail_maxsize_mail"];
00079                                 $settings["mail_maxsize_attach"] = $_POST["mail_maxsize_attach"];
00080                                 $settings["mail_maxsize_box"] = $_POST["mail_maxsize_box"];
00081                                 $settings["mail_maxtime_mail"] = $_POST["mail_maxtime_mail"];
00082                                 $settings["mail_maxtime_attach"] = $_POST["mail_maxtime_attach"];
00083                         }
00084                         else // all required fields ok
00085                         {
00086 
00088                 // write new settings
00089 
00090                                 // mail server
00091                                 $this->ilias->setSetting("mail_server",$_POST["mail_server"]);
00092                                 $this->ilias->setSetting("mail_port",$_POST["mail_port"]);
00093 
00094                                 // internal mail
00095 #                               $this->ilias->setSetting("mail_intern_enable",$_POST["mail_intern_enable"]);
00096                                 $this->ilias->setSetting("mail_maxsize_mail",$_POST["mail_maxsize_mail"]);
00097                                 $this->ilias->setSetting("mail_maxsize_attach",$_POST["mail_maxsize_attach"]);
00098                                 $this->ilias->setSetting("mail_maxsize_box",$_POST["mail_maxsize_box"]);
00099                                 $this->ilias->setSetting("mail_maxtime_mail",$_POST["mail_maxtime_mail"]);
00100                                 $this->ilias->setSetting("mail_maxtime_attach",$_POST["mail_maxtime_attach"]);
00101 
00102                                 $settings = $this->ilias->getAllSettings();
00103 
00104                                 // feedback
00105                                 sendInfo($this->lng->txt("saved_successfully"));
00106                         }
00107                 }
00108 
00110                 // setting language vars
00111 
00112                 // common
00113                 $this->tpl->setVariable("TXT_DAYS",$this->lng->txt("days"));
00114                 $this->tpl->setVariable("TXT_KB",$this->lng->txt("kb"));
00115 
00116                 // mail server
00117                 $this->tpl->setVariable("TXT_MAIL_SMTP", $this->lng->txt("mail")." (".$this->lng->txt("smtp").")");
00118                 $this->tpl->setVariable("TXT_MAIL_SERVER", $this->lng->txt("server"));
00119                 $this->tpl->setVariable("TXT_MAIL_PORT", $this->lng->txt("port"));
00120 
00121                 // internal mail
00122                 $this->tpl->setVariable("TXT_MAIL_INTERN", $this->lng->txt("mail")." (".$this->lng->txt("internal_system").")");
00123 #               $this->tpl->setVariable("TXT_MAIL_INTERN_ENABLE", $this->lng->txt("mail_intern_enable"));
00124                 $this->tpl->setVariable("TXT_MAIL_MAXSIZE_MAIL", $this->lng->txt("mail_maxsize_mail"));
00125                 $this->tpl->setVariable("TXT_MAIL_MAXSIZE_ATTACH", $this->lng->txt("mail_maxsize_attach"));
00126                 $this->tpl->setVariable("TXT_MAIL_MAXSIZE_BOX", $this->lng->txt("mail_maxsize_box"));
00127                 $this->tpl->setVariable("TXT_MAIL_MAXTIME_MAIL", $this->lng->txt("mail_maxtime_mail"));
00128                 $this->tpl->setVariable("TXT_MAIL_MAXTIME_ATTACH", $this->lng->txt("mail_maxtime_attach"));
00129                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
00130 
00132                 // display formula data
00133 
00134                 // mail server
00135                 $this->tpl->setVariable("MAIL_SERVER",$settings["mail_server"]);
00136                 $this->tpl->setVariable("MAIL_PORT",$settings["mail_port"]);
00137 
00138                 // internal mail
00139 #               if ($settings["mail_intern_enable"] == "y")
00140 #               {
00141 #                       $this->tpl->setVariable("MAIL_INTERN_ENABLE","checked=\"checked\"");
00142 #               }
00143 
00144                 $this->tpl->setVariable("MAIL_MAXSIZE_MAIL", $settings["mail_maxsize_mail"]);
00145                 $this->tpl->setVariable("MAIL_MAXSIZE_ATTACH", $settings["mail_maxsize_attach"]);
00146                 $this->tpl->setVariable("MAIL_MAXSIZE_BOX", $settings["mail_maxsize_box"]);
00147                 $this->tpl->setVariable("MAIL_MAXTIME_MAIL", $settings["mail_maxtime_mail"]);
00148                 $this->tpl->setVariable("MAIL_MAXTIME_ATTACH", $settings["mail_maxtime_attach"]);
00149 
00150                 $this->tpl->parseCurrentBlock();
00151         }
00152 
00153         function importObject()
00154         {
00155                 global $rbacsystem,$lng;
00156 
00157                 if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
00158                 {
00159                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
00160                 }
00161                 $this->getTemplateFile("import");
00162 
00163                 // GET ALREADY CREATED UPLOADED XML FILE
00164                 $this->__initFileObject();
00165                 if($this->file_obj->findXMLFile())
00166                 {
00167                         $this->tpl->setVariable("TXT_IMPORTED_FILE",$lng->txt("checked_files"));
00168                         $this->tpl->setVariable("XML_FILE",basename($this->file_obj->getXMLFile()));
00169 
00170                         $this->tpl->setVariable("BTN_IMPORT",$this->lng->txt("import"));
00171                 }
00172 
00173                 $this->tpl->setVariable("FORMACTION",
00174                         $this->ctrl->getFormAction($this));
00175                 $this->tpl->setVariable("TXT_IMPORT_MAIL",$this->lng->txt("table_mail_import"));
00176                 $this->tpl->setVariable("TXT_IMPORT_FILE",$this->lng->txt("mail_import_file"));
00177                 $this->tpl->setVariable("BTN_CANCEL",$this->lng->txt("cancel"));
00178                 $this->tpl->setVariable("BTN_UPLOAD",$this->lng->txt("upload"));
00179 
00180                 return true;
00181         }
00182 
00183         function performImportObject()
00184         {
00185                 global $rbacsystem,$lng;
00186 
00187                 if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
00188                 {
00189                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
00190                 }
00191                 $this->__initFileObject();
00192                 $this->file_obj->findXMLFile();
00193                 $this->__initParserObject($this->file_obj->getXMLFile(),"import");
00194                 $this->parser_obj->startParsing();
00195                 $number = $this->parser_obj->getCountImported();
00196                 sendInfo($lng->txt("import_finished")." ".$number,true);
00197                 
00198                 $this->ctrl->redirect($this, "import");
00199         }
00200         
00201         
00202 
00203         function uploadObject()
00204         {
00205                 global $rbacsystem,$lng;
00206 
00207                 if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
00208                 {
00209                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
00210                 }
00211                 
00212                 $this->__initFileObject();
00213                 if(!$this->file_obj->storeUploadedFile($_FILES["importFile"]))  // STEP 1 save file in ...import/mail
00214                 {
00215                         $this->message = $lng->txt("import_file_not_valid"); 
00216                         $this->file_obj->unlinkLast();
00217                 }
00218                 else if(!$this->file_obj->unzip())
00219                 {
00220                         $this->message = $lng->txt("cannot_unzip_file");                                        // STEP 2 unzip uplaoded file
00221                         $this->file_obj->unlinkLast();
00222                 }
00223                 else if(!$this->file_obj->findXMLFile())                                                // STEP 3 getXMLFile
00224                 {
00225                         $this->message = $lng->txt("cannot_find_xml");
00226                         $this->file_obj->unlinkLast();
00227                 }
00228                 else if(!$this->__initParserObject($this->file_obj->getXMLFile(),"check"))
00229                 {
00230                         $this->message = $lng->txt("error_parser");                             // STEP 4 init sax parser
00231                 }
00232                 else if(!$this->parser_obj->startParsing())
00233                 {
00234                         $this->message = $lng->txt("users_not_imported").":<br/>"; // STEP 5 start parsing
00235                         $this->message .= $this->parser_obj->getNotAssignableUsers();
00236                 }
00237                 // FINALLY CHECK ERROR
00238                 if(!$this->message)
00239                 {
00240                         $this->message = $lng->txt("uploaded_and_checked");
00241                 }
00242                 sendInfo($this->message,true);
00243                 
00244                 $this->ctrl->redirect($this, "import");
00245         }
00246 
00247         // PRIVATE
00248         function __initFileObject()
00249         {
00250                 include_once "./classes/class.ilFileDataImportMail.php";
00251 
00252                 $this->file_obj =& new ilFileDataImportMail();
00253 
00254                 return true;
00255         }
00256         function __initParserObject($a_xml,$a_mode)
00257         {
00258                 include_once "./classes/class.ilMailImportParser.php";
00259 
00260                 if(!$a_xml)
00261                 {
00262                         return false;
00263                 }
00264 
00265                 $this->parser_obj =& new ilMailImportParser($a_xml,$a_mode);
00266                 
00267                 return true;
00268         }
00269         
00270         function &executeCommand()
00271         {
00272                 $next_class = $this->ctrl->getNextClass($this);
00273                 $cmd = $this->ctrl->getCmd();
00274                 $this->prepareOutput();
00275 
00276                 switch($next_class)
00277                 {
00278                         case 'ilpermissiongui':
00279                                 include_once("./classes/class.ilPermissionGUI.php");
00280                                 $perm_gui =& new ilPermissionGUI($this);
00281                                 $ret =& $this->ctrl->forwardCommand($perm_gui);
00282                                 break;
00283 
00284                         default:
00285                                 if(!$cmd)
00286                                 {
00287                                         $cmd = "view";
00288                                 }
00289                                 $cmd .= "Object";
00290                                 $this->$cmd();
00291 
00292                                 break;
00293                 }
00294                 return true;
00295         }
00296         
00297         function getAdminTabs(&$tabs_gui)
00298         {
00299                 $this->getTabs($tabs_gui);
00300         }
00301         
00307         function getTabs(&$tabs_gui)
00308         {
00309                 global $rbacsystem;
00310 
00311                 if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00312                 {
00313                         $tabs_gui->addTarget("settings",
00314                                 $this->ctrl->getLinkTarget($this, "view"), array("view",""), "", "");
00315                 }
00316 
00317                 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
00318                 {
00319                         $tabs_gui->addTarget("perm_settings",
00320                                 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
00321                 }
00322                 
00323                 if ($rbacsystem->checkAccess('write',$this->object->getRefId()))
00324                 {
00325                         $tabs_gui->addTarget("import",
00326                                 $this->ctrl->getLinkTarget($this, "import"), "import", "", "");
00327                 }
00328         }
00329 } // END class.ilObjMailGUI
00330 ?>

Generated on Fri Dec 13 2013 13:52:07 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1