3 * scmhook postReceiveEmail Plugin Class
4 * Copyright 2013, Benoit Debaenst - TrivialDev
6 * This file is part of FusionForge. FusionForge is free software;
7 * you can redistribute it and/or modify it under the terms of the
8 * GNU General Public License as published by the Free Software
9 * Foundation; either version 2 of the Licence, or (at your option)
12 * FusionForge is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 require_once $gfplugins.'scmhook/common/scmhook.class.php';
25 class postReceiveEmail extends scmhook {
29 function __construct() {
30 $this->group = $GLOBALS['group'];
31 $this->name = "Post Receive Email";
32 $this->description = _('Commit message log is pushed to commit mailing-list of the project');
33 $this->classname = "postReceiveEmail";
34 $this->hooktype = "post-receive";
35 $this->label = "scmgit";
36 $this->unixname = "postreceiveemail";
41 function isAvailable() {
43 require_once $gfcommon.'mail/MailingList.class.php';
44 require_once $gfcommon.'mail/MailingListFactory.class.php';
46 if ($this->group->usesMail()) {
47 $mlFactory = new MailingListFactory($this->group);
48 $mlArray = $mlFactory->getMailingLists();
49 $mlCount = count($mlArray);
50 for ($j = 0; $j < $mlCount; $j++) {
51 $currentList =& $mlArray[$j];
52 if ($currentList->getListEmail() == $this->group->getUnixName().'-commits@'.forge_get_config('lists_host'))
55 $this->disabledMessage = _('Hook not available due to missing dependency : Project has no commit mailing-list: ').$this->group->getUnixName().'-commits';
57 $this->disabledMessage = _('Hook not available due to missing dependency : Project not using mailing-list.');
62 function getDisabledMessage() {
63 return $this->disabledMessage;