1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* Copyright (c) STMicroelectronics, 2007. All Rights Reserved. |
4
|
|
|
* |
5
|
|
|
* Originally written by Manuel Vacelet, 2007 |
6
|
|
|
* |
7
|
|
|
* This file is a part of Codendi. |
8
|
|
|
* |
9
|
|
|
* Codendi is free software; you can redistribute it and/or modify |
10
|
|
|
* it under the terms of the GNU General Public License as published by |
11
|
|
|
* the Free Software Foundation; either version 2 of the License, or |
12
|
|
|
* (at your option) any later version. |
13
|
|
|
* |
14
|
|
|
* Codendi is distributed in the hope that it will be useful, |
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17
|
|
|
* GNU General Public License for more details. |
18
|
|
|
* |
19
|
|
|
* You should have received a copy of the GNU General Public License |
20
|
|
|
* along with Codendi; if not, write to the Free Software |
21
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22
|
|
|
* |
23
|
|
|
* |
24
|
|
|
*/ |
25
|
|
|
require_once('common/mail/Mail.class.php'); |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Use this class to hook email management in codendi. |
29
|
|
|
* How to use it: |
30
|
|
|
* 1. make a link on it in src/common/mail |
31
|
|
|
* 2. customize $this->_testDir to a directory the http server you run is |
32
|
|
|
* allowed to write |
33
|
|
|
* 3. Replace in the target code 'Mail.class.php' by 'FakeMail.class.php' |
34
|
|
|
* and 'new Mail()' by 'new FakeMail()' |
35
|
|
|
* 4. All the mail send will be stored in $this->_testDir/maillog (one after |
36
|
|
|
* the others) |
37
|
|
|
*/ |
38
|
|
|
class FakeMail extends Mail { |
39
|
|
|
|
40
|
|
|
function FakeMail() { |
41
|
|
|
parent::Mail(); |
|
|
|
|
42
|
|
|
$this->_testDir = '/var/tmp/codendi_cache/mail'; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
function _sendmail($headers) { |
46
|
|
|
$fd = fopen($this->_testDir.'/maillog', 'a'); |
47
|
|
|
if($fd) { |
48
|
|
|
$to = "To: ".$this->getTo()."\n"; |
49
|
|
|
$subj = "Subject: ".$this->getEncodedSubject()."\n"; |
50
|
|
|
fwrite($fd, $headers); |
51
|
|
|
fwrite($fd, $to); |
52
|
|
|
fwrite($fd, $subj); |
53
|
|
|
fwrite($fd, "\n"); |
54
|
|
|
fwrite($fd, $this->getBody()); |
55
|
|
|
fwrite($fd, "\n"); |
56
|
|
|
fwrite($fd, "\n"); |
57
|
|
|
fclose($fd); |
58
|
|
|
return true; |
59
|
|
|
} |
60
|
|
|
return false; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
?> |
66
|
|
|
|
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.