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

mail.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.ilObjUser.php";
00036 require_once "classes/class.ilMailbox.php";
00037 require_once "classes/class.ilMail.php";
00038 
00039 $lng->loadLanguageModule("mail");
00040 $umail = new ilMail($_SESSION["AccountId"]);
00041 $mbox = new ilMailBox($_SESSION["AccountId"]);
00042 
00043 // CHECK HACK
00044 if (!$rbacsystem->checkAccess("mail_visible",$umail->getMailObjectReferenceId()))
00045 {
00046         $ilias->raiseError($lng->txt("permission_denied"),$ilias->error_obj->WARNING);
00047 }
00048 
00049 $tpl->addBlockFile("CONTENT", "content", "tpl.mail.html");
00050 $tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00051 // display infopanel if something happened
00052 $tpl->setVariable("TXT_MAILS_OF",$lng->txt("mail_mails_of"));
00053 infoPanel();
00054 
00055 // IF THERE IS NO OBJ_ID GIVEN GET THE ID OF MAIL ROOT NODE
00056 if(!$_GET["mobj_id"])
00057 {
00058         $_GET["mobj_id"] = $mbox->getInboxFolder();
00059 }
00060 
00061 if(isset($_GET["sent"]))
00062 {
00063         sendInfo($lng->txt("mail_message_send"));
00064 }
00065 
00066 // IF REQUESTED FROM mail_read.php
00067 if(isset($_GET["mail_id"]))
00068 {
00069         $_POST["cmd"]["submit"] = true;
00070         $_POST["action"] = 'delete';
00071         $_POST["mail_id"] = array($_GET["mail_id"]);
00072 }
00073 setLocator($_GET["mobj_id"],$_SESSION["AccountId"],"");
00074 
00075 if (isset($_POST["cmd"]["submit"]))
00076 {
00077         switch ($_POST["action"])
00078         {
00079                 case 'mark_read':
00080                         if(is_array($_POST["mail_id"]))
00081                         {
00082                                 $umail->markRead($_POST["mail_id"]);
00083                         }
00084                         else
00085                         {
00086                                 sendInfo($lng->txt("mail_select_one"));
00087                         }
00088                         break;
00089                 case 'mark_unread':
00090                         if(is_array($_POST["mail_id"]))
00091                         {
00092                                 $umail->markUnread($_POST["mail_id"]);
00093                         }
00094                         else
00095                         {
00096                                 sendInfo($lng->txt("mail_select_one"));
00097                         }
00098                         break;
00099 
00100                 case 'delete':
00101                         // IF MAILBOX IS TRASH ASK TO CONFIRM
00102                         if($mbox->getTrashFolder() == $_GET["mobj_id"])
00103                         {
00104                                 if(!is_array($_POST["mail_id"]))
00105                                 {
00106                                         sendInfo($lng->txt("mail_select_one"));
00107                                         $error_delete = true;
00108                                 }
00109                                 else
00110                                 {
00111                                         sendInfo($lng->txt("mail_sure_delete"));
00112                                 }
00113                         } // END IF MAILBOX IS TRASH FOLDER
00114                         else
00115                         {
00116                                 // MOVE MAILS TO TRASH
00117                                 if(!is_array($_POST["mail_id"]))
00118                                 {
00119                                         sendInfo($lng->txt("mail_select_one"));
00120                                 }
00121                                 else if($umail->moveMailsToFolder($_POST["mail_id"],$mbox->getTrashFolder()))
00122                                 {
00123                                         sendInfo($lng->txt("mail_moved_to_trash"));
00124                                 }
00125                                 else
00126                                 {
00127                                         sendInfo($lng->txt("mail_move_error"));
00128                                 }
00129                         }
00130                         break;
00131 
00132                 case 'add':
00133                         header("location: mail_options.php?mobj_id=$_GET[mobj_id]&cmd=add");
00134                         exit;
00135 
00136                 default:
00137                         if(!is_array($_POST["mail_id"]))
00138                         {
00139                                 sendInfo($lng->txt("mail_select_one"));
00140                         }
00141                         else if($umail->moveMailsToFolder($_POST["mail_id"],$_POST["action"]))
00142                         {
00143                                 sendInfo($lng->txt("mail_moved"));
00144                         }
00145                         else
00146                         {
00147                                 sendInfo($lng->txt("mail_move_error"));
00148                         }
00149                         break;
00150         }
00151 }
00152 // ONLY IF FOLDER IS TRASH, IT WAS ASKED FOR CONFIRMATION
00153 if($mbox->getTrashFolder() == $_GET["mobj_id"])
00154 {
00155         if(isset($_POST["cmd"]["confirm"]))
00156         {
00157                 if(!is_array($_POST["mail_id"]))
00158                 {
00159                         sendInfo($lng->txt("mail_select_one"));
00160                 }
00161                 else if($umail->deleteMails($_POST["mail_id"]))
00162                 {
00163                         sendInfo($lng->txt("mail_deleted"));
00164                 }
00165                 else
00166                 {
00167                         sendInfo($lng->txt("mail_delete_error"));
00168                 }
00169         }
00170         if(isset($_POST["cmd"]["cancel"]))
00171         {
00172                 header("location: mail.php?mobj_id=$_GET[mobj_id]");
00173                 exit;
00174         }
00175 }
00176 
00177 include("./include/inc.mail_buttons.php");
00178 
00179 $tpl->setVariable("ACTION", "mail.php?mobj_id=$_GET[mobj_id]");
00180 
00181 // BEGIN CONFIRM_DELETE
00182 if($_POST["action"] == "delete" and !$error_delete and !isset($_POST["cmd"]["confirm"]) and $mbox->getTrashFolder() == $_GET["mobj_id"])
00183 {
00184         $tpl->setCurrentBlock("CONFIRM_DELETE");
00185         $tpl->setVariable("BUTTON_CONFIRM",$lng->txt("confirm"));
00186         $tpl->setVariable("BUTTON_CANCEL",$lng->txt("cancel"));
00187         $tpl->parseCurrentBlock();
00188 }
00189 
00190 // BEGIN MAIL ACTIONS
00191 $actions = $mbox->getActions($_GET["mobj_id"]);
00192 
00193 $tpl->setCurrentBlock("mailactions");
00194 foreach($actions as $key => $action)
00195 {
00196         if($key == 'move')
00197         {
00198                 $folders = $mbox->getSubFolders();
00199                 foreach($folders as $folder)
00200                 {
00201                         $tpl->setVariable("MAILACTION_VALUE", $folder["obj_id"]);
00202                         if($folder["type"] != 'user_folder')
00203                         {
00204                                 $tpl->setVariable("MAILACTION_NAME",$action." ".$lng->txt("mail_".$folder["title"]));
00205                         }
00206                         else
00207                         {
00208                                 $tpl->setVariable("MAILACTION_NAME",$action." ".$folder["title"]);
00209                         }
00210                         $tpl->parseCurrentBlock();
00211                 }
00212         }
00213         else
00214         {
00215                 $tpl->setVariable("MAILACTION_NAME", $action);
00216                 $tpl->setVariable("MAILACTION_VALUE", $key);
00217                 $tpl->setVariable("MAILACTION_SELECTED",$_POST["action"] == 'delete' ? 'selected' : '');
00218                 $tpl->parseCurrentBlock();
00219         }
00220 }
00221 // END MAIL ACTIONS
00222 
00223 
00224 // SHOW_FOLDER ONLY IF viewmode is flatview
00225 if(!isset($_SESSION["viewmode"]) or $_SESSION["viewmode"] == 'flat')
00226 {
00227         $tpl->setCurrentBlock("show_folder");
00228         $tpl->setCurrentBLock("flat_select");
00229    
00230         foreach($folders as $folder)
00231         {
00232                 if($folder["obj_id"] == $_GET["mobj_id"])
00233                 {
00234                         $tpl->setVariable("FLAT_SELECTED","selected");
00235                 }
00236                 $tpl->setVariable("FLAT_VALUE",$folder["obj_id"]);
00237                 if($folder["type"] == 'user_folder')
00238                 {
00239                         $tpl->setVariable("FLAT_NAME", $folder["title"]);
00240                 }
00241                 else
00242                 {
00243                         $tpl->setVariable("FLAT_NAME", $lng->txt("mail_".$folder["title"]));
00244                 }
00245                 $tpl->parseCurrentBlock();
00246         }
00247         $tpl->setVariable("TXT_FOLDERS", $lng->txt("mail_change_to_folder"));
00248         $tpl->setVariable("FOLDER_VALUE",$lng->txt("submit"));
00249         $tpl->parseCurrentBlock();
00250 }
00251 // END SHOW_FOLDER
00252 $tpl->setVariable("ACTION_FLAT","mail.php");
00253 
00254 // BEGIN MAILS
00255 $mail_data = $umail->getMailsOfFolder($_GET["mobj_id"]);
00256 $mail_count = count($mail_data);
00257 
00258 // TODO: READ FROM MAIL_OPTIONS
00259 $mail_max_hits = 20;
00260 $counter = 0;
00261 foreach ($mail_data as $mail)
00262 {
00263         if($mail["sender_id"] and !ilObjectFactory::ObjectIdExists($mail["sender_id"]))
00264         {
00265                 --$mail_count;
00266                 continue;
00267         }
00268         // LINKBAR
00269         if($mail_count > $mail_max_hits)
00270         {
00271                 $params = array(
00272                         "mobj_id"               => $_GET["mobj_id"]);
00273         }
00274         $start = $_GET["offset"];
00275         $linkbar = ilUtil::Linkbar(basename($_SERVER["PHP_SELF"]),$mail_count,$mail_max_hits,$start,$params);
00276         if ($linkbar)
00277         {
00278                 $tpl->setVariable("LINKBAR", $linkbar);
00279         }
00280         if($counter >= ($start+$mail_max_hits))
00281         {
00282                 break;
00283         }
00284         if($counter < $start)
00285         {
00286                 ++$counter;
00287                 continue;
00288         }
00289 
00290         // END LINKBAR
00291         ++$counter;
00292         $tpl->setCurrentBlock("mails");
00293         $tpl->setVariable("ROWCOL","tblrow".(($counter % 2)+1));
00294         $tpl->setVariable("MAIL_ID", $mail["mail_id"]);
00295 
00296         if(is_array($_POST["mail_id"]))
00297         {
00298                 $tpl->setVariable("CHECKBOX_CHECKED",in_array($mail["mail_id"],$_POST["mail_id"]) ? 'checked' : "");
00299         }
00300 
00301         // GET FULLNAME OF SENDER
00302         
00303         if($_GET['mobj_id'] == $mbox->getSentFolder() or $_GET['mobj_id'] == $mbox->getDraftsFolder())
00304         {
00305                 if($mail['rcp_to'])
00306                 {
00307                         $tpl->setVariable("MAIL_LOGIN",$mail['rcp_to']);
00308                 }
00309                 else
00310                 {
00311                         $tpl->setVariable("MAIL_LOGIN",$lng->txt('not_available'));
00312                 }
00313         }
00314         else
00315         {
00316                 $tmp_user = new ilObjUser($mail["sender_id"]);
00317                 $tpl->setVariable("MAIL_FROM", $tmp_user->getFullname());
00318                 if(!($login = $tmp_user->getLogin()))
00319                 {
00320                         $login = $mail["import_name"]." (".$lng->txt("imported").")";
00321                 }
00322                 $tpl->setVariable("MAIL_LOGIN",$login);
00323         }
00324         $tpl->setVariable("MAILCLASS", $mail["m_status"] == 'read' ? 'mailread' : 'mailunread');
00325         // IF ACTUAL FOLDER IS DRAFT BOX, DIRECT TO COMPOSE MESSAGE
00326         if($_GET["mobj_id"] == $mbox->getDraftsFolder())
00327         {
00328                 $tpl->setVariable("MAIL_LINK_READ", "mail_new.php?mail_id=".
00329                                                   $mail["mail_id"]."&mobj_id=$_GET[mobj_id]&type=draft");
00330         }
00331         else
00332         {
00333                 $tpl->setVariable("MAIL_LINK_READ", "mail_read.php?mail_id=".
00334                                                   $mail["mail_id"]."&mobj_id=$_GET[mobj_id]");
00335         }
00336         $tpl->setVariable("MAIL_SUBJECT", htmlspecialchars($mail["m_subject"]));
00337         $tpl->setVariable("MAIL_DATE", ilFormat::formatDate($mail["send_time"]));
00338         $tpl->parseCurrentBlock();
00339 }
00340 // END MAILS
00341 
00342 //headline
00343 $tpl->setVariable("TXT_MAIL", $lng->txt("mail"));
00344 $tpl->setVariable("TXT_MAIL_S", $lng->txt("mail_s"));
00345 $tpl->setVariable("TXT_UNREAD", $lng->txt("unread"));
00346 $tpl->setVariable("TXT_SUBMIT",$lng->txt("submit"));
00347 $tpl->setVariable("TXT_SELECT_ALL", $lng->txt("select_all"));
00348 $tpl->setVariable("IMGPATH",$tpl->tplPath);
00349 
00350 // MAIL SUMMARY
00351 $mail_counter = $umail->getMailCounterData();
00352 $tpl->setVariable("MAIL_COUNT", $mail_counter["total"]);
00353 $tpl->setVariable("MAIL_COUNT_UNREAD", $mail_counter["unread"]);
00354 $tpl->setVariable("TXT_UNREAD_MAIL_S",$lng->txt("mail_s_unread"));
00355 $tpl->setVariable("TXT_MAIL_S",$lng->txt("mail_s"));
00356 
00357 //columns headlines
00358 if($_GET['mobj_id'] == $mbox->getSentFolder() or $_GET['mobj_id'] == $mbox->getDraftsFolder())
00359 {
00360         $tpl->setVariable("TXT_SENDER", $lng->txt("recipient"));
00361 }
00362 else
00363 {
00364         $tpl->setVariable("TXT_SENDER", $lng->txt("sender"));
00365 }
00366 $tpl->setVariable("TXT_SUBJECT", $lng->txt("subject"));
00367 //      $tpl->setVariable("MAIL_SORT_SUBJ","link");
00368 $tpl->setVariable("TXT_DATE",$lng->txt("date"));
00369 $tpl->setVariable("DIRECTION", "up");
00370 
00371 $tpl->show();
00372 
00373 ?>

Generated on Fri Dec 13 2013 09:06:36 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1