• 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 
00037 require_once "class.ilObjectGUI.php";
00038 
00039 class ilObjMailGUI extends ilObjectGUI
00040 {
00045         function ilObjMailGUI($a_data,$a_id,$a_call_by_reference)
00046         {
00047                 $this->type = "mail";
00048                 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference, false);
00049         }
00050 
00051         function viewObject()
00052         {
00053 #               parent::editObject();
00054                 
00055                 $this->lng->loadLanguageModule("mail");
00056 
00057                 $this->tpl->addBlockFile("SYSTEMSETTINGS", "systemsettings", "tpl.mail_basicdata.html", "Services/Mail");
00058                 $this->tpl->setCurrentBlock("systemsettings");
00059 
00060                 $settings = $this->ilias->getAllSettings();
00061 
00062                 if (isset($_POST["save_settings"]))  // formular sent
00063                 {
00064                         //init checking var
00065                         $form_valid = true;
00066                         
00067                         // put any checks here!!!
00068 
00069                         if (!$form_valid)       //required fields not satisfied. Set formular to already fill in values
00070                         {
00071                                 // mail server
00072                                 $settings["mail_server"] = $_POST["mail_server"];
00073                                 $settings["mail_port"] = $_POST["mail_port"];
00074 
00075                                 // internal mail
00076 #                               $settings["mail_intern_enable"] = $_POST["mail_intern_enable"];
00077                                 $settings["mail_maxsize_mail"] = $_POST["mail_maxsize_mail"];
00078                                 $settings["mail_maxsize_attach"] = $_POST["mail_maxsize_attach"];
00079                                 $settings["mail_maxsize_box"] = $_POST["mail_maxsize_box"];
00080                                 $settings["mail_maxtime_mail"] = $_POST["mail_maxtime_mail"];
00081                                 $settings["mail_maxtime_attach"] = $_POST["mail_maxtime_attach"];
00082                                 $settings['mail_external_sender_noreply'] = ilUtil::stripSlashes($_POST['mail_external_sender_noreply']);
00083                                 
00084                                 
00085                         }
00086                         else // all required fields ok
00087                         {
00088 
00090                 // write new settings
00091 
00092                                 // mail server
00093                                 $this->ilias->setSetting("mail_server",$_POST["mail_server"]);
00094                                 $this->ilias->setSetting("mail_port",$_POST["mail_port"]);
00095 
00096                                 // internal mail
00097                                 $this->ilias->setSetting("mail_incoming_mail",$_POST["mail_incoming_mail"]);
00098 
00099 #                               $this->ilias->setSetting("mail_intern_enable",$_POST["mail_intern_enable"]);
00100                                 $this->ilias->setSetting("mail_maxsize_mail",$_POST["mail_maxsize_mail"]);
00101                                 $this->ilias->setSetting("mail_maxsize_attach",$_POST["mail_maxsize_attach"]);
00102                                 $this->ilias->setSetting("mail_maxsize_box",$_POST["mail_maxsize_box"]);
00103                                 $this->ilias->setSetting("mail_maxtime_mail",$_POST["mail_maxtime_mail"]);
00104                                 $this->ilias->setSetting("mail_maxtime_attach",$_POST["mail_maxtime_attach"]);
00105                                 $this->ilias->setSetting("pear_mail_enable",$_POST["pear_mail_enable"]);
00106                                 $this->ilias->setSetting('mail_external_sender_noreply', ilUtil::stripSlashes($_POST['mail_external_sender_noreply']));
00107 
00108                                 $settings = $this->ilias->getAllSettings();
00109 
00110                                 // feedback
00111                                 ilUtil::sendInfo($this->lng->txt("saved_successfully"));
00112                         }
00113                 }
00114 
00116                 // setting language vars
00117 
00118                 // common
00119                 $this->tpl->setVariable("TXT_DAYS",$this->lng->txt("days"));
00120                 $this->tpl->setVariable("TXT_KB",$this->lng->txt("kb"));
00121 
00122                 // mail server
00123                 $this->tpl->setVariable("TXT_MAIL_SMTP", $this->lng->txt("mail")." (".$this->lng->txt("smtp").")");
00124                 $this->tpl->setVariable("TXT_MAIL_SERVER", $this->lng->txt("server"));
00125                 $this->tpl->setVariable("TXT_MAIL_PORT", $this->lng->txt("port"));
00126 
00127                 // Pear Mail extension
00128                 // Note: We use the include statement to determine whether PEAR MAIL is
00129                 //      installed. We use the @ operator to prevent PHP from issuing a
00130                 //      warning while we test for PEAR MAIL.
00131                 $is_pear_mail_installed = @include_once 'Mail/RFC822.php';
00132                 $this->tpl->setVariable("TXT_PEAR_MAIL", $this->lng->txt("mail_use_pear_mail"));
00133                 if ($settings['pear_mail_enable'] && $is_pear_mail_installed) 
00134                 {
00135                         $this->tpl->setVariable("PEAR_MAIL_CHECKED", 'checked="checked"');
00136                 }
00137                 if ($is_pear_mail_installed)
00138                 {
00139                         $this->tpl->setVariable("TXT_PEAR_MAIL_INFO", 
00140                                 $this->lng->txt("mail_use_pear_mail_info")
00141                         );
00142                 }
00143                 else
00144                 {
00145                         $this->tpl->setVariable("TXT_PEAR_MAIL_INFO", 
00146                                 $this->lng->txt("mail_use_pear_mail_info").'<br>'.
00147                                 $this->lng->txt("mail_pear_mail_needed")
00148                         );
00149                         $this->tpl->setVariable("PEAR_MAIL_DISABLED", 'disabled="disabled"');
00150                 }
00151 
00152                 // internal mail
00153                 include_once "Services/Mail/classes/class.ilMailOptions.php";
00154                 $this->tpl->setVariable("TXT_GENERAL_SETTINGS", $this->lng->txt("general_settings"));
00155                 $this->tpl->setVariable("TXT_MAIL_INCOMING", $this->lng->txt("mail_incoming"));
00156                 $types = array(
00157                         array(
00158                                 "name" => $this->lng->txt("mail_incoming_local"),
00159                                 "value" => IL_MAIL_LOCAL
00160                         ),
00161                         array(
00162                                 "name" => $this->lng->txt("mail_incoming_smtp"),
00163                                 "value" => IL_MAIL_EMAIL
00164                         ),
00165                         array(
00166                                 "name" => $this->lng->txt("mail_incoming_both"),
00167                                 "value" => IL_MAIL_BOTH
00168                         )
00169                 );
00170                 for ($i = 0; $i < count($types); $i++)
00171                 {
00172                         $this->tpl->setCurrentBlock("loop_incoming_mail");
00173                         $this->tpl->setVariable("LOOP_INCOMING_MAIL_VALUE", $types[$i]["value"]);
00174                         $this->tpl->setVariable("LOOP_INCOMING_MAIL_NAME", $types[$i]["name"]);
00175                         if ($settings["mail_incoming_mail"] == $types[$i]["value"])
00176                         {
00177                                 $this->tpl->setVariable("LOOP_INCOMING_MAIL_SELECTED", "selected");
00178                         }
00179                         $this->tpl->parseCurrentBlock("loop_incoming_mail");
00180                 }
00181 
00182 #               $this->tpl->setVariable("TXT_MAIL_INTERN", $this->lng->txt("mail")." (".$this->lng->txt("internal_system").")");
00183                 $this->tpl->setVariable("TXT_MAIL_INTERN", $this->lng->txt("internal_system"));
00184 #               $this->tpl->setVariable("TXT_MAIL_INTERN_ENABLE", $this->lng->txt("mail_intern_enable"));
00185                 $this->tpl->setVariable("TXT_MAIL_MAXSIZE_MAIL", $this->lng->txt("mail_maxsize_mail"));
00186                 $this->tpl->setVariable("TXT_MAIL_MAXSIZE_ATTACH", $this->lng->txt("mail_maxsize_attach"));
00187                 $this->tpl->setVariable("TXT_MAIL_MAXSIZE_BOX", $this->lng->txt("mail_maxsize_box"));
00188                 $this->tpl->setVariable("TXT_MAIL_MAXTIME_MAIL", $this->lng->txt("mail_maxtime_mail"));
00189                 $this->tpl->setVariable("TXT_MAIL_MAXTIME_ATTACH", $this->lng->txt("mail_maxtime_attach"));
00190                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
00191 
00193                 // display formula data
00194 
00195                 // mail server
00196                 $this->tpl->setVariable("MAIL_SERVER",$settings["mail_server"]);
00197                 $this->tpl->setVariable("MAIL_PORT",$settings["mail_port"]);
00198 
00199                 // internal mail
00200 #               if ($settings["mail_intern_enable"] == "y")
00201 #               {
00202 #                       $this->tpl->setVariable("MAIL_INTERN_ENABLE","checked=\"checked\"");
00203 #               }
00204 
00205                 $this->tpl->setVariable("MAIL_MAXSIZE_MAIL", $settings["mail_maxsize_mail"]);
00206                 $this->tpl->setVariable("MAIL_MAXSIZE_ATTACH", $settings["mail_maxsize_attach"]);
00207                 $this->tpl->setVariable("MAIL_MAXSIZE_BOX", $settings["mail_maxsize_box"]);
00208                 $this->tpl->setVariable("MAIL_MAXTIME_MAIL", $settings["mail_maxtime_mail"]);
00209                 $this->tpl->setVariable("MAIL_MAXTIME_ATTACH", $settings["mail_maxtime_attach"]);
00210                 
00211                 // noreply
00212                 $this->tpl->setVariable('TXT_MAIL_EXTERNAL_SENDER_NOREPLY', $this->lng->txt('mail_external_sender_noreply'));
00213                 $this->tpl->setVariable('MAIL_EXTERNAL_SENDER_NOREPLY', $settings['mail_external_sender_noreply']);
00214                 $this->tpl->setVariable('INFO_MAIL_EXTERNAL_SENDER_NOREPLY', $this->lng->txt('info_mail_external_sender_noreply'));             
00215 
00216                 $this->tpl->parseCurrentBlock();
00217         }
00218 
00219         function importObject()
00220         {
00221                 global $rbacsystem,$lng;
00222 
00223                 if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
00224                 {
00225                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
00226                 }
00227                 #$this->getTemplateFile("import");
00228                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mail_import.html", "Services/Mail");
00229 
00230                 // GET ALREADY CREATED UPLOADED XML FILE
00231                 $this->__initFileObject();
00232                 if($this->file_obj->findXMLFile())
00233                 {
00234                         $this->tpl->setVariable("TXT_IMPORTED_FILE",$lng->txt("checked_files"));
00235                         $this->tpl->setVariable("XML_FILE",basename($this->file_obj->getXMLFile()));
00236 
00237                         $this->tpl->setVariable("BTN_IMPORT",$this->lng->txt("import"));
00238                 }
00239 
00240                 $this->tpl->setVariable("FORMACTION",
00241                         $this->ctrl->getFormAction($this));
00242                 $this->tpl->setVariable("TXT_IMPORT_MAIL",$this->lng->txt("table_mail_import"));
00243                 $this->tpl->setVariable("TXT_IMPORT_FILE",$this->lng->txt("mail_import_file"));
00244                 $this->tpl->setVariable("BTN_CANCEL",$this->lng->txt("cancel"));
00245                 $this->tpl->setVariable("BTN_UPLOAD",$this->lng->txt("upload"));
00246 
00247                 return true;
00248         }
00249 
00250         function performImportObject()
00251         {
00252                 global $rbacsystem,$lng;
00253 
00254                 if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
00255                 {
00256                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
00257                 }
00258                 $this->__initFileObject();
00259                 $this->file_obj->findXMLFile();
00260                 $this->__initParserObject($this->file_obj->getXMLFile(),"import");
00261                 $this->parser_obj->startParsing();
00262                 $number = $this->parser_obj->getCountImported();
00263                 ilUtil::sendInfo($lng->txt("import_finished")." ".$number,true);
00264                 
00265                 $this->ctrl->redirect($this, "import");
00266         }
00267         
00268         
00269 
00270         function uploadObject()
00271         {
00272                 global $rbacsystem,$lng;
00273 
00274                 if (!$rbacsystem->checkAccess('write',$this->object->getRefId()))
00275                 {
00276                         $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->WARNING);
00277                 }
00278                 
00279                 $this->__initFileObject();
00280                 if(!$this->file_obj->storeUploadedFile($_FILES["importFile"]))  // STEP 1 save file in ...import/mail
00281                 {
00282                         $this->message = $lng->txt("import_file_not_valid"); 
00283                         $this->file_obj->unlinkLast();
00284                 }
00285                 else if(!$this->file_obj->unzip())
00286                 {
00287                         $this->message = $lng->txt("cannot_unzip_file");                                        // STEP 2 unzip uplaoded file
00288                         $this->file_obj->unlinkLast();
00289                 }
00290                 else if(!$this->file_obj->findXMLFile())                                                // STEP 3 getXMLFile
00291                 {
00292                         $this->message = $lng->txt("cannot_find_xml");
00293                         $this->file_obj->unlinkLast();
00294                 }
00295                 else if(!$this->__initParserObject($this->file_obj->getXMLFile(),"check"))
00296                 {
00297                         $this->message = $lng->txt("error_parser");                             // STEP 4 init sax parser
00298                 }
00299                 else if(!$this->parser_obj->startParsing())
00300                 {
00301                         $this->message = $lng->txt("users_not_imported").":<br/>"; // STEP 5 start parsing
00302                         $this->message .= $this->parser_obj->getNotAssignableUsers();
00303                 }
00304                 // FINALLY CHECK ERROR
00305                 if(!$this->message)
00306                 {
00307                         $this->message = $lng->txt("uploaded_and_checked");
00308                 }
00309                 ilUtil::sendInfo($this->message,true);
00310                 
00311                 $this->ctrl->redirect($this, "import");
00312         }
00313 
00314         // PRIVATE
00315         function __initFileObject()
00316         {
00317                 include_once "./classes/class.ilFileDataImportMail.php";
00318 
00319                 $this->file_obj =& new ilFileDataImportMail();
00320 
00321                 return true;
00322         }
00323         function __initParserObject($a_xml,$a_mode)
00324         {
00325                 include_once "Services/Mail/classes/class.ilMailImportParser.php";
00326 
00327                 if(!$a_xml)
00328                 {
00329                         return false;
00330                 }
00331 
00332                 $this->parser_obj =& new ilMailImportParser($a_xml,$a_mode);
00333                 
00334                 return true;
00335         }
00336         
00337         function &executeCommand()
00338         {
00339                 $next_class = $this->ctrl->getNextClass($this);
00340                 $cmd = $this->ctrl->getCmd();
00341                 $this->prepareOutput();
00342 
00343                 switch($next_class)
00344                 {
00345                         case 'ilpermissiongui':
00346                                 include_once("./classes/class.ilPermissionGUI.php");
00347                                 $perm_gui =& new ilPermissionGUI($this);
00348                                 $ret =& $this->ctrl->forwardCommand($perm_gui);
00349                                 break;
00350 
00351                         default:
00352                                 if(!$cmd)
00353                                 {
00354                                         $cmd = "view";
00355                                 }
00356                                 $cmd .= "Object";
00357                                 $this->$cmd();
00358 
00359                                 break;
00360                 }
00361                 return true;
00362         }
00363         
00364         function getAdminTabs(&$tabs_gui)
00365         {
00366                 $this->getTabs($tabs_gui);
00367         }
00368         
00374         function getTabs(&$tabs_gui)
00375         {
00376                 global $rbacsystem;
00377 
00378                 if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00379                 {
00380                         $tabs_gui->addTarget("settings",
00381                                 $this->ctrl->getLinkTarget($this, "view"), array("view",""), "", "");
00382                 }
00383 
00384                 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
00385                 {
00386                         $tabs_gui->addTarget("perm_settings",
00387                                 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
00388                 }
00389                 
00390                 if ($rbacsystem->checkAccess('write',$this->object->getRefId()))
00391                 {
00392                         $tabs_gui->addTarget("import",
00393                                 $this->ctrl->getLinkTarget($this, "import"), "import", "", "");
00394                 }
00395         }
00396 } // END class.ilObjMailGUI
00397 ?>

Generated on Fri Dec 13 2013 17:56:48 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1