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

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

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