ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilMailImportParser Class Reference

Mail Import Parser. More...

+ Inheritance diagram for ilMailImportParser:
+ Collaboration diagram for ilMailImportParser:

Public Member Functions

 __construct ($a_xml_file, $a_mode)
 Constructor. More...
 
 getMode ()
 
 getCountImported ()
 
 getNotAssignableUsers ()
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class private More...
 
 startParsing ()
 start the parser More...
 
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 handler for begin of element More...
 
 handlerEndTag ($a_xml_parser, $a_name)
 handler for end of element More...
 
 handlerCharacterData ($a_xml_parser, $a_data)
 handler for character data More...
 
 __insert ()
 
 __buildSQLArray ()
 
- Public Member Functions inherited from ilSaxParser
 __construct ($a_xml_file='', $throwException=false)
 Constructor setup ILIAS global object public. More...
 
 setXMLContent ($a_xml_content)
 
 getXMLContent ()
 
 getInputType ()
 
 startParsing ()
 stores xml data in array More...
 
 createParser ()
 create parser More...
 
 setOptions ($a_xml_parser)
 set parser options More...
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class private More...
 
 openXMLFile ()
 open xml file More...
 
 parse ($a_xml_parser, $a_fp=null)
 parse xml file More...
 
 freeParser ($a_xml_parser)
 free xml parser handle More...
 
 setThrowException ($throwException)
 set error handling More...
 
- Public Member Functions inherited from PEAR
 __construct ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). More...
 
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes. More...
 
 isError ($data, $code=null)
 Tell whether a value is a PEAR error. More...
 
 expectError ($code=' *')
 This method is used to tell which errors you expect to get. More...
 
 popExpect ()
 This method pops one element off the expected error codes stack. More...
 
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available. More...
 
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack. More...
 
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. More...
 
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options. More...
 
 staticPushErrorHandling ($mode, $options=null)
 
 staticPopErrorHandling ()
 
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack. More...
 
 popErrorHandling ()
 Pop the last error handler used. More...
 
 loadExtension ($ext)
 OS independant PHP extension load. More...
 

Data Fields

 $mode
 
 $counter
 
- Data Fields inherited from ilSaxParser
 $input_type = null
 
 $xml_content = ''
 
 $ilias
 
 $lng
 
 $xml_file
 
 $throwException = false
 
- Data Fields inherited from PEAR
 $_debug = false
 
 $_default_error_mode = null
 
 $_default_error_options = null
 
 $_default_error_handler = ''
 
 $_error_class = 'PEAR_Error'
 
 $_expected_errors = array()
 

Additional Inherited Members

- Static Public Member Functions inherited from PEAR
static & getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them. More...
 
static setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. More...
 
- Protected Member Functions inherited from ilSaxParser
 handleError ($message, $code)
 use given error handler to handle error message or internal ilias error message handle More...
 

Detailed Description

Mail Import Parser.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id
Id
class.ilMailImportParser.php,v 1.2 2004/04/08 09:59:55 smeyer Exp

Definition at line 15 of file class.ilMailImportParser.php.

Constructor & Destructor Documentation

◆ __construct()

ilMailImportParser::__construct (   $a_xml_file,
  $a_mode 
)

Constructor.

Parameters
string$a_xml_filexml file

public

Definition at line 28 of file class.ilMailImportParser.php.

29  {
30  define('EXPORT_VERSION',4);
31 
32  parent::__construct($a_xml_file);
33  $this->mode = $a_mode;
34  $this->counter = -1;
35  }

Member Function Documentation

◆ __buildSQLArray()

ilMailImportParser::__buildSQLArray ( )

Definition at line 257 of file class.ilMailImportParser.php.

References $ilDB, and array.

Referenced by __insert().

258  {
259  global $ilDB;
260 
261  $sql = array();
262 
263  if(!count($this->mails))
264  {
265  return array();
266  }
267 
268  foreach($this->mails as $mail)
269  {
270  $sql[] = (array('0',
271  addslashes($mail["usr_id"]),
272  addslashes($mail["folder_id"]),
273  addslashes($mail["sender_id"]),
274  addslashes(serialize(array())),
275  addslashes($mail["send_time"]),
276  addslashes($mail["rcp_to"]),
277  addslashes($mail["rcp_cc"]),
278  addslashes($mail["rcp_bcc"]),
279  addslashes($mail["read"]),
280  addslashes(serialize(array("normal"))),
281  addslashes($mail["m_email"]),
282  addslashes($mail["m_subject"]),
283  addslashes($mail["m_message"]),
284  addslashes($mail["import_name"])));
285 
286  }
287  return $sql ? $sql :array();
288  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ __insert()

ilMailImportParser::__insert ( )

Definition at line 247 of file class.ilMailImportParser.php.

References $ilDB, and __buildSQLArray().

Referenced by startParsing().

248  {
249  global $ilDB;
250 
251  $sth = $ilDB->prepare("INSERT INTO mail VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
252 
253  $ilDB->executeMultiple($sth,$this->__buildSQLArray());
254 
255  return true;
256  }
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCountImported()

ilMailImportParser::getCountImported ( )

Definition at line 42 of file class.ilMailImportParser.php.

43  {
44  return count($this->mails);
45  }

◆ getMode()

ilMailImportParser::getMode ( )

Definition at line 37 of file class.ilMailImportParser.php.

References $mode.

Referenced by startParsing().

38  {
39  return $this->mode;
40  }
+ Here is the caller graph for this function:

◆ getNotAssignableUsers()

ilMailImportParser::getNotAssignableUsers ( )

Definition at line 47 of file class.ilMailImportParser.php.

48  {
49  if(count($this->not_imported))
50  {
51  return implode("<br/>",$this->not_imported);
52  }
53  return "";
54  }

◆ handlerBeginTag()

ilMailImportParser::handlerBeginTag (   $a_xml_parser,
  $a_name,
  $a_attribs 
)

handler for begin of element

Definition at line 95 of file class.ilMailImportParser.php.

References $counter, $ilErr, and ilObjUser\_getImportedUserId().

96  {
97  global $ilErr;
98 
99  switch($a_name)
100  {
101  case "users":
102  if($a_attribs["exportVersion"] < EXPORT_VERSION)
103  {
104  $ilErr->raiseError("!!! This export Version isn't supported, update your ILIAS 2 installation"
105  ,$ilErr->WARNING);
106  }
107  break;
108 
109  case "user":
110  if(!($this->i3_id = ilObjUser::_getImportedUserId($a_attribs["id"])))
111  {
112  $this->not_imported[] = $a_attribs["id"];
113  }
114  break;
115 
116  case "mail":
117  if($this->i3_id)
118  {
119  $this->mails[++$this->counter]["usr_id"] = $this->i3_id;
120  $this->mails[$this->counter]["m_email"] = $a_attribs["asEmail"];
121 
122  // SET FOLDER ID = 0 FOR SYSTEM MESSAGES
123  if($a_attribs["systemMessage"])
124  {
125  $this->mails[$this->counter]["folder_id"] = 0;
126  }
127  }
128  break;
129 
130  case "sender":
131  if($this->i3_id)
132  {
133  $sender = ilObjUser::_getImportedUserId($a_attribs["id"]);
134  $this->mails[$this->counter]["sender_id"] = $sender;
135  $this->mails[$this->counter]["import_name"] = $a_attribs["import_name"];
136  }
137  break;
138 
139 
140  default:
141  // Do nothing
142  break;
143  }
144  }
global $ilErr
Definition: raiseError.php:16
static _getImportedUserId($i2_id)
+ Here is the call graph for this function:

◆ handlerCharacterData()

ilMailImportParser::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

handler for character data

Definition at line 232 of file class.ilMailImportParser.php.

233  {
234  // i don't know why this is necessary, but
235  // the parser seems to convert "&gt;" to ">" and "&lt;" to "<"
236  // in character data, but we don't want that, because it's the
237  // way we mask user html in our content, so we convert back...
238  $a_data = str_replace("<","&lt;",$a_data);
239  $a_data = str_replace(">","&gt;",$a_data);
240 
241  if(!empty($a_data))
242  {
243  $this->cdata .= $a_data;
244  }
245  }

◆ handlerEndTag()

ilMailImportParser::handlerEndTag (   $a_xml_parser,
  $a_name 
)

handler for end of element

Definition at line 150 of file class.ilMailImportParser.php.

References $counter, and date.

151  {
152  // STOP IF USER IS NOT ASSIGNABLE
153  if(!$this->i3_id)
154  {
155  $this->cdata = '';
156  return;
157  }
158  switch($a_name)
159  {
160  case "targetFolder":
161  if(!isset($this->mails[$this->counter]["folder_id"]))
162  {
163  $tmp_mailbox = new ilMailbox($this->i3_id);
164  switch($this->cdata)
165  {
166  case "inbox":
167  $this->mails[$this->counter]["folder_id"] = $tmp_mailbox->getInboxFolder();
168  $this->mails[$this->counter]["read"] = "unread";
169  break;
170  case "sentbox":
171  $this->mails[$this->counter]["folder_id"] = $tmp_mailbox->getSentFolder();
172  $this->mails[$this->counter]["read"] = "read";
173  break;
174  case "draft":
175  $this->mails[$this->counter]["folder_id"] = $tmp_mailbox->getDraftsFolder();
176  $this->mails[$this->counter]["read"] = "read";
177  break;
178  case "trash":
179  $this->mails[$this->counter]["folder_id"] = $tmp_mailbox->getTrashFolder();
180  $this->mails[$this->counter]["read"] = "read";
181  break;
182  }
183  }
184  break;
185 
186  case "sendTime":
187  $this->mails[$this->counter]["send_time"] = date("Y-m-d H:i:s",$this->cdata);
188  $this->mails[$this->counter]["timest"] = date("YmdHis",$this->cdata);
189  break;
190 
191  case "to":
192  $this->mails[$this->counter]["rcp_to"] = $this->cdata;
193  break;
194 
195  case "cc":
196  $this->mails[$this->counter]["rcp_cc"] = $this->cdata;
197  break;
198 
199  case "bcc":
200  $this->mails[$this->counter]["rcp_bcc"] = $this->cdata;
201  break;
202 
203  case "url":
204  if($this->cdata)
205  {
206  $this->mails[$this->counter]["m_message"] = "Url: ".$this->cdata." <br>";
207  }
208  break;
209 
210  case "urlDescription":
211  if($this->cdata)
212  {
213  $this->mails[$this->counter]["m_message"] .= $this->cdata."<br>";
214  }
215  break;
216 
217  case "subject":
218  $this->mails[$this->counter]["m_subject"] = $this->cdata;
219  break;
220 
221  case "message":
222  $this->mails[$this->counter]["m_message"] .= $this->cdata;
223  break;
224  }
225  $this->cdata = '';
226  }
Mail Box class Base class for creating and handling mail boxes.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())

◆ setHandlers()

ilMailImportParser::setHandlers (   $a_xml_parser)

set event handler should be overwritten by inherited class private

Definition at line 61 of file class.ilMailImportParser.php.

62  {
63  xml_set_object($a_xml_parser,$this);
64  xml_set_element_handler($a_xml_parser,'handlerBeginTag','handlerEndTag');
65  xml_set_character_data_handler($a_xml_parser,'handlerCharacterData');
66  }

◆ startParsing()

ilMailImportParser::startParsing ( )

start the parser

Definition at line 71 of file class.ilMailImportParser.php.

References __insert(), and getMode().

72  {
73  parent::startParsing();
74 
75  switch($this->getMode())
76  {
77  case "check":
78  if(count($this->not_imported))
79  {
80  return false;
81  }
82  break;
83 
84  case "import":
85  $this->__insert();
86  break;
87  }
88  return true;
89  }
+ Here is the call graph for this function:

Field Documentation

◆ $counter

ilMailImportParser::$counter

Definition at line 18 of file class.ilMailImportParser.php.

Referenced by handlerBeginTag(), and handlerEndTag().

◆ $mode

ilMailImportParser::$mode

Definition at line 17 of file class.ilMailImportParser.php.

Referenced by getMode().


The documentation for this class was generated from the following file: