From: Franck Villaume Date: Sat, 9 Mar 2013 16:33:56 +0000 (+0100) Subject: fix #528: complains about forums when creating mailing-list even if forum tool is... X-Git-Tag: v5.2.2~42^2~9 X-Git-Url: https://scm.fusionforge.org/anonscm/gitweb?p=fusionforge%2Ffusionforge.git;a=commitdiff_plain;h=dd7afaa5129bd518836c549eca43ef9c61c30410 fix #528: complains about forums when creating mailing-list even if forum tool is deactivated --- diff --git a/src/common/forum/Forum.class.php b/src/common/forum/Forum.class.php index 697f406f4c..df91168563 100644 --- a/src/common/forum/Forum.class.php +++ b/src/common/forum/Forum.class.php @@ -6,6 +6,7 @@ * Copyright 2002, Tim Perdue/GForge, LLC * Copyright 2009, Roland Mas * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent + * Copyright 2013, Franck Villaume - TrivialDev * * This file is part of FusionForge. FusionForge is free software; * you can redistribute it and/or modify it under the terms of the @@ -598,6 +599,17 @@ class Forum extends Error { return false; } + $project_name = $this->Group->getUnixName(); + $result_list_samename = db_query_params('SELECT 1 FROM mail_group_list WHERE list_name=$1 AND group_id=$2', + + array($project_name.'-'.strtolower($forum_name), + $this->Group->getID())); + + if (db_numrows($result_list_samename) > 0){ + $this->setError(_('Mailing List Exists with same name')); + return false; + } + $res = db_query_params('UPDATE forum_group_list SET forum_name=$1, description=$2, diff --git a/src/common/include/utils.php b/src/common/include/utils.php index 6c1914d9d3..82099263ca 100644 --- a/src/common/include/utils.php +++ b/src/common/include/utils.php @@ -8,6 +8,7 @@ * Copyright (c) 2010, 2011, 2012 * Thorsten Glaser * Copyright 2010-2011, Alain Peyrat - Alcatel-Lucent + * Copyright 2013, Franck Villaume - TrivialDev * * This file is part of FusionForge. FusionForge is free software; * you can redistribute it and/or modify it under the terms of the @@ -1219,37 +1220,41 @@ function util_ensure_value_in_set ($value, $set) { function check_email_available($group, $email, &$response) { // Check if a mailing list with same name already exists - $mlFactory = new MailingListFactory($group); - if (!$mlFactory || !is_object($mlFactory) || $mlFactory->isError()) { - $response .= $mlFactory->getErrorMessage(); - return false; - } - $mlArray = $mlFactory->getMailingLists(); - if ($mlFactory->isError()) { - $response .= $mlFactory->getErrorMessage(); - return false; - } - for ($j = 0; $j < count($mlArray); $j++) { - $currentList =& $mlArray[$j]; - if ($email == $currentList->getName()) { - $response .= _('Error: a mailing list with the same email address already exists.'); + if ($group->usesMail()) { + $mlFactory = new MailingListFactory($group); + if (!$mlFactory || !is_object($mlFactory) || $mlFactory->isError()) { + $response .= $mlFactory->getErrorMessage(); return false; } + $mlArray = $mlFactory->getMailingLists(); + if ($mlFactory->isError()) { + $response .= $mlFactory->getErrorMessage(); + return false; + } + for ($j = 0; $j < count($mlArray); $j++) { + $currentList =& $mlArray[$j]; + if ($email == $currentList->getName()) { + $response .= _('Error: a mailing list with the same email address already exists.'); + return false; + } + } } // Check if a forum with same name already exists - $ff = new ForumFactory($group); - if (!$ff || !is_object($ff) || $ff->isError()) { - $response .= $ff->getErrorMessage(); - return false; - } - $farr = $ff->getForums(); - $prefix = $group->getUnixName() . '-'; - for ($j = 0; $j < count($farr); $j++) { - if (is_object($farr[$j])) { - if ($email == $prefix . $farr[$j]->getName()) { - $response .= _('Error: a forum with the same email address already exists.'); - return false; + if ($group->usesForum()) { + $ff = new ForumFactory($group); + if (!$ff || !is_object($ff) || $ff->isError()) { + $response .= $ff->getErrorMessage(); + return false; + } + $farr = $ff->getForums(); + $prefix = $group->getUnixName() . '-'; + for ($j = 0; $j < count($farr); $j++) { + if (is_object($farr[$j])) { + if ($email == $prefix . $farr[$j]->getName()) { + $response .= _('Error: a forum with the same email address already exists.'); + return false; + } } } }