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

Services/Mail/classes/class.ilMailGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2006 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 require_once "Services/Mail/classes/class.ilMail.php";
00025 
00034 class ilMailGUI
00035 {
00036         private $tpl = null;
00037         private $ctrl = null;
00038         private $lng = null;
00039         private $tabs_gui = null;
00040         
00041         private $umail = null;
00042         private $exp = null;
00043         private $output = null;
00044         private $mtree = null;
00045         private $forwardClass = null;
00046 
00047         public function __construct()
00048         {
00049                 global $tpl, $ilCtrl, $lng, $rbacsystem, $ilErr, $ilUser;
00050 
00051                 $this->tpl = $tpl;
00052                 $this->ctrl = $ilCtrl;
00053                 $this->lng = $lng;
00054                 
00055                 $this->ctrl->saveParameter($this, "mobj_id");
00056                 $this->lng->loadLanguageModule("mail");
00057 
00058                 $this->umail = new ilMail($ilUser->getId());
00059 
00060                 // CHECK HACK
00061                 if (!$rbacsystem->checkAccess("mail_visible", $this->umail->getMailObjectReferenceId()))
00062                 {
00063                         $ilErr->raiseError($this->lng->txt("permission_denied"), $ilErr->WARNING);
00064                 }
00065         }
00066 
00067         public function executeCommand()
00068         {
00069                 global $ilUser;
00070                 // Check for incomplete profile
00071                 if($ilUser->getProfileIncomplete())
00072                 {
00073                         ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
00074                 }
00075                 
00076                 
00077                 if ($_GET["type"] == "search_res")
00078                 {
00079                         $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "searchResults");
00080                         $this->ctrl->redirectByClass("ilmailformgui");
00081                 }
00082 
00083                 if ($_GET["type"] == "attach")
00084                 {
00085                         $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "mailAttachment");
00086                         $this->ctrl->redirectByClass("ilmailformgui");
00087                 }
00088 
00089                 if ($_GET["type"] == "new")
00090                 {
00091                         $_SESSION['rcp_to'] = $_GET['rcp_to'];                  
00092                         $_SESSION['rcp_cc'] = $_GET['rcp_cc'];
00093                         $_SESSION['rcp_bcc'] = $_GET['rcp_bcc'];
00094                         
00095                         $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "mailUser");
00096                         $this->ctrl->redirectByClass("ilmailformgui");
00097                 }
00098 
00099                 if ($_GET["type"] == "reply")
00100                 {
00101                         $_SESSION['mail_id'] = $_GET['mail_id'];
00102                         $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "replyMail");
00103                         $this->ctrl->redirectByClass("ilmailformgui");
00104                 }
00105 
00106                 if ($_GET["type"] == "read")
00107                 {
00108                         $_SESSION['mail_id'] = $_GET['mail_id'];
00109                         $this->ctrl->setParameterByClass("ilmailfoldergui", "cmd", "showMail");
00110                         $this->ctrl->redirectByClass("ilmailfoldergui");
00111                 }
00112 
00113                 if ($_GET["type"] == "deliverFile")
00114                 {
00115                         $_SESSION['mail_id'] = $_GET['mail_id'];
00116                         $_SESSION['filename'] = ($_POST["filename"] ? $_POST["filename"] : $_GET["filename"]);
00117                         $this->ctrl->setParameterByClass("ilmailfoldergui", "cmd", "deliverFile");
00118                         $this->ctrl->redirectByClass("ilmailfoldergui");
00119                 }
00120                 
00121                 if ($_GET["type"] == "message_sent")
00122                 {
00123                         ilUtil::sendInfo($this->lng->txt('mail_message_send'), true);
00124                         $this->ctrl->redirectByClass("ilmailfoldergui");
00125                 }
00126 
00127                 if ($_GET["type"] == "role")
00128                 {
00129                         if (is_array($_POST['roles']))
00130                         {
00131                                 $_SESSION['mail_roles'] = $_POST['roles'];
00132                         }
00133                         else if ($_GET["role"])
00134                         {
00135                                 $_SESSION['mail_roles'] = array($_GET["role"]);
00136                         }
00137                         $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "mailRole");
00138                         $this->ctrl->redirectByClass("ilmailformgui");
00139                 }
00140 
00141                 if ($_GET["view"] == "my_courses")
00142                 {
00143                         $_SESSION['search_crs'] = $_GET['search_crs'];
00144                         $this->ctrl->setParameterByClass("ilmailformgui", "cmd", "searchCoursesTo");
00145                         $this->ctrl->redirectByClass("ilmailformgui");
00146                 }
00147 
00148                 if (isset($_GET["viewmode"]))
00149                 {
00150                         $_SESSION["viewmode"] = $_GET["viewmode"];
00151                         $this->ctrl->setCmd("setViewMode");
00152                 }
00153                 
00154                 $this->forwardClass = $this->ctrl->getNextClass($this);
00155 
00156                 if ($this->ctrl->getCmd() != "showMenu")
00157                 {
00158                         $this->showHeader();
00159                 }
00160 
00161                 switch($this->forwardClass)
00162                 {
00163                         case 'ilmailmenugui':
00164                                 include_once 'Services/Mail/classes/class.ilMailMenuGUI.php';
00165 
00166                                 $this->ctrl->forwardCommand(new ilMailMenuGUI());
00167                                 break;
00168 
00169                         case 'ilmailformgui':
00170                                 include_once 'Services/Mail/classes/class.ilMailFormGUI.php';
00171 
00172                                 $this->ctrl->forwardCommand(new ilMailFormGUI());
00173                                 break;
00174 
00175                         case 'ilmailaddressbookgui':
00176                                 include_once 'Services/Mail/classes/class.ilMailAddressbookGUI.php';
00177 
00178                                 $this->ctrl->forwardCommand(new ilMailAddressbookGUI());
00179                                 break;
00180 
00181                         case 'ilmailoptionsgui':
00182                                 include_once 'Services/Mail/classes/class.ilMailOptionsGUI.php';
00183 
00184                                 $this->ctrl->forwardCommand(new ilMailOptionsGUI());
00185                                 break;
00186 
00187                         case 'ilmailfoldergui':
00188                                 include_once 'Services/Mail/classes/class.ilMailFolderGUI.php';
00189 
00190                                 $this->ctrl->forwardCommand(new ilMailFolderGUI());
00191                                 break;
00192 
00193                         default:
00194                                 if (!($cmd = $this->ctrl->getCmd()))
00195                                 {
00196                                         $cmd = "setViewMode";
00197                                 }
00198 
00199                                 $this->$cmd();
00200                                 break;
00201 
00202                 }
00203                 return true;
00204         }
00205 
00206         private function setViewMode()
00207         {
00208                 if ($_GET["target"] == "")
00209                 {
00210                         $_GET["target"] = "ilmailfoldergui";
00211                 }
00212                 if ($_SESSION["viewmode"] == "tree")
00213                 {
00214                         include_once("Services/Frameset/classes/class.ilFramesetGUI.php");
00215                         $fs_gui = new ilFramesetGUI();
00216                         $fs_gui->setFramesetTitle($this->lng->txt("mail"));
00217                         $fs_gui->setMainFrameName("content");
00218                         $fs_gui->setSideFrameName("tree");
00219                 
00220                         $this->ctrl->setParameter($this, "cmd", "showMenu");
00221                         $this->ctrl->setParameter($this, "mexpand", 1);
00222                         $fs_gui->setSideFrameSource($this->ctrl->getLinkTarget($this));
00223                         $this->ctrl->clearParameters($this);
00224                 
00225                         if ($_GET["type"] == "add_subfolder")
00226                         {
00227                                 $fs_gui->setMainFrameSource($this->ctrl->getLinkTargetByClass($_GET["target"], "addSubFolder"));
00228                         }
00229                         else if ($_GET["type"] == "enter_folderdata")
00230                         {
00231                                 $fs_gui->setMainFrameSource($this->ctrl->getLinkTargetByClass($_GET["target"], "enterFolderData"));
00232                         }
00233                         else if ($_GET["type"] == "confirmdelete_folderdata")
00234                         {
00235                                 $fs_gui->setMainFrameSource($this->ctrl->getLinkTargetByClass($_GET["target"], "confirmDeleteFolder"));
00236                         }
00237                         else
00238                         {
00239                                 $fs_gui->setMainFrameSource($this->ctrl->getLinkTargetByClass($_GET["target"]));
00240                         }
00241                         $fs_gui->show();
00242                 }
00243                 else
00244                 {
00245                         $this->ctrl->redirectByClass($_GET["target"]);
00246                 }
00247         }
00248         
00249         private function showHeader()
00250         {
00251                 global $ilMainMenu;
00252 
00253                 $ilMainMenu->setActive("mail");
00254 
00255                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
00256                 $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00257                 $this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_mail_b.gif"));
00258                 
00259                 // display infopanel if something happened
00260                 ilUtil::infoPanel();
00261 
00262                 $this->tpl->addBlockFile("TABS", "tabs", "tpl.tabs.html");
00263 
00264                 // FOLDER
00265                 $this->tpl->setCurrentBlock("tab");
00266                 $this->tpl->setVariable("TAB_TYPE", $this->forwardClass == "ilmailfoldergui"
00267                         ? "tabactive"
00268                         : "tabinactive");
00269                 #$this->ctrl->setParameterByClass("ilmailfoldergui", "type", "new");
00270                 $this->tpl->setVariable("TAB_LINK", $this->ctrl->getLinkTargetByClass("ilmailfoldergui"));
00271                 $this->ctrl->clearParametersByClass("ilmailfoldergui");
00272                 $this->tpl->setVariable("TAB_TEXT", $this->lng->txt("fold"));
00273                 $this->tpl->parseCurrentBlock();
00274                 
00275                 
00276                 // COMPOSE
00277                 $this->tpl->setCurrentBlock("tab");
00278                 $this->tpl->setVAriable("TAB_TYPE", $this->forwardClass == "ilmailformgui"
00279                         ? "tabactive"
00280                         : "tabinactive");
00281                 $this->ctrl->setParameterByClass("ilmailformgui", "type", "new");
00282                 $this->tpl->setVariable("TAB_LINK", $this->ctrl->getLinkTargetByClass("ilmailformgui"));
00283                 $this->ctrl->clearParametersByClass("ilmailformgui");
00284                 $this->tpl->setVariable("TAB_TEXT", $this->lng->txt("compose"));
00285                 $this->tpl->parseCurrentBlock();
00286                 
00287                 // ADDRESSBOOK
00288                 $this->tpl->setCurrentBlock("tab");
00289                 $this->tpl->setVAriable("TAB_TYPE", $this->forwardClass == "ilmailaddressbookgui"
00290                         ? "tabactive"
00291                         : "tabinactive");
00292                 $this->tpl->setVariable("TAB_LINK", $this->ctrl->getLinkTargetByClass("ilmailaddressbookgui"));
00293                 $this->tpl->setVariable("TAB_TEXT", $this->lng->txt("mail_addressbook"));
00294                 $this->tpl->parseCurrentBlock();
00295                 
00296                 // OPTIONS
00297                 $this->tpl->setCurrentBlock("tab");
00298                 $this->tpl->setVAriable("TAB_TYPE", $this->forwardClass == "ilmailoptionsgui"
00299                         ? "tabactive"
00300                         : "tabinactive");
00301                 $this->tpl->setVariable("TAB_LINK", $this->ctrl->getLinkTargetByClass("ilmailoptionsgui"));
00302                 $this->tpl->setVariable("TAB_TEXT", $this->lng->txt("options"));
00303                 $this->tpl->parseCurrentBlock();
00304                 
00305                 // FLATVIEW <-> TREEVIEW
00306                 if (!isset($_SESSION["viewmode"]) or $_SESSION["viewmode"] == "flat")
00307                 {
00308                         $this->ctrl->setParameter($this, "viewmode", "tree");
00309                         $this->tpl->setTreeFlatIcon(
00310                                 $this->ctrl->getLinkTarget($this),
00311                                 "tree");
00312                         //$this->tpl->setVariable("IMG_TREE", ilUtil::getImagePath("ic_treeview.gif"));
00313                         //$this->tpl->parseCurrentBlock();
00314                 }
00315                 else
00316                 {
00317                         $this->ctrl->setParameter($this, "viewmode", "flat");
00318                         $this->tpl->setTreeFlatIcon(
00319                                 $this->ctrl->getLinkTarget($this),
00320                                 "flat");
00321                         //$this->tpl->parseCurrentBlock();
00322                 }
00323                 $this->ctrl->clearParameters($this);
00324                 $this->tpl->setCurrentBlock("tree_icons");
00325                 $this->tpl->parseCurrentBlock();
00326         }
00327 
00328         private function showMenu()
00329         {
00330                 global $ilUser;
00331                 
00332                 require_once "Services/Mail/classes/class.ilMailExplorer.php";
00333 
00334                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
00335                 $this->tpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.gif", false));
00336                 
00337                 $this->exp = new ilMailExplorer($this->ctrl->getLinkTargetByClass("ilmailfoldergui"),$ilUser->getId());
00338                 $this->exp->setTargetGet("mobj_id");
00339 
00340                 if ($_GET["mexpand"] == "")
00341                 {
00342                         $this->mtree = new ilTree($ilUser->getId());
00343                         $this->mtree->setTableNames('mail_tree','mail_obj_data');
00344                         $expanded = $this->mtree->readRootId();
00345                 }
00346                 else
00347                         $expanded = $_GET["mexpand"];
00348                         
00349                 $this->exp->setExpand($expanded);
00350                 
00351                 //build html-output
00352                 $this->exp->setOutput(0);
00353                 $this->output = $this->exp->getOutput();
00354 
00355                 $this->tpl->setCurrentBlock("content");
00356                 $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("mail_folders"));
00357                 $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
00358                 $this->tpl->setVariable("EXPLORER",$this->output);
00359                 $this->ctrl->setParameter($this, "cmd", "showMenu");
00360                 $this->ctrl->setParameter($this, "mexpand", $_GET["mexpand"]);
00361                 $this->tpl->setVariable("ACTION", $this->ctrl->getLinkTarget($this));
00362                 $this->tpl->parseCurrentBlock();
00363                 
00364                 $this->tpl->show(false);
00365         }
00366 }
00367 
00368 ?>

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