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

Modules/Chat/classes/class.ilFileDataChat.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 
00032 require_once("classes/class.ilFileData.php");
00033                                 
00034 class ilFileDataChat extends ilFileData
00035 {
00036         var $chat_obj;
00037 
00043         var $chat_path;
00044 
00052         function ilFileDataChat(&$chat_obj)
00053         {
00054 
00055                 parent::ilFileData();
00056                 
00057                 $this->chat_obj =& $chat_obj;
00058                 $this->chat_path = parent::getPath()."/chat";
00059 
00060                 if(!$this->__checkPath())
00061                 {
00062                         $this->__createDirectory($this->chat_path);
00063                 }
00064                 $this->__deleteOld();
00065                 
00066                 if(@is_dir($this->chat_path."/chatrooms_".$_SESSION["AccountId"]))
00067                 {
00068                         ilUtil::delDir($this->chat_path."/chatrooms_".$_SESSION["AccountId"]);
00069                 }
00070                 $this->__createDirectory($this->chat_path."/chatrooms_".$_SESSION["AccountId"]);
00071         }
00072 
00073         function addFile($filename,$data)
00074         {
00075                 $fp = @fopen($this->chat_path."/chatrooms_".$_SESSION["AccountId"]."/".$filename,"w+");
00076 
00077                 fwrite($fp,$data);
00078                 fclose($fp);
00079 
00080                 return $this->chat_path."/chatrooms_".$_SESSION["AccountId"];
00081         }
00082 
00083         function zip()
00084         {
00085                 ilUtil::zip($this->chat_path."/chatrooms_".$_SESSION["AccountId"],
00086                                         $this->chat_path."/ilias_chat.zip");
00087 
00088                 return $this->chat_path."/ilias_chat.zip";
00089         }
00090 
00091         function getChatPath()
00092         {
00093                 return $this->chat_path;
00094         }
00095 
00096         // DESTUCTOR CALLED BY PEAR BASE CLASS
00097         function _ilFileDataChat()
00098         {
00099                 ilUtil::delDir($this->chat_path);
00100         }
00101         // PRIVATE
00102         function __checkPath()
00103         {
00104                 if(!file_exists($this->getChatPath()))
00105                 {
00106                         return false;
00107                 }
00108                 return true;
00109         }
00110 
00111         function __createDirectory($a_path)
00112         {
00113                 return ilUtil::makeDir($a_path);
00114         }
00115 
00116         function __deleteOld()
00117         {
00118                 if(is_dir($this->getChatPath()))
00119                 {
00120                         $dp = opendir($this->getChatPath());
00121                         while(($file = readdir($dp)) !== false)
00122                         {
00123                                 if($file != '.' and $file != '..')
00124                                 {
00125                                         if(filectime($this->getChatPath()."/".$file) < (time() - 60*60*24))
00126                                         {
00127                                                 ilUtil::delDir($this->getChatPath()."/".$file);
00128                                         }
00129                                 }
00130                         }
00131                         closedir($dp);
00132                 }
00133         }
00134 }
00135 ?>

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