* Copyright (c) 2010, 2011, 2012
* Thorsten Glaser <t.glaser@tarent.de>
* 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
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;
+ }
}
}
}
function util_mkdtemp($suffix = '', $prefix = 'tmp') {
$tempdir = sys_get_temp_dir();
for ($i=0; $i<5; $i++) {
- $id = strtr(base64_encode(openssl_random_pseudo_bytes(6)), '+/', '-_');
+ $id = strtr(base64_encode(util_randbytes(6)), '+/', '-_');
$path = "{$tempdir}/{$prefix}{$id}{$suffix}";
if (mkdir($path, 0700)) {
return $path;
if ($userinfo === False) {
return False;
}
- if (posix_setegid($userinfo['gid']) && posix_seteuid($userinfo['uid'])) {
+ if (posix_setegid($userinfo['gid']) &&
+ ($saved_euid != 0 || posix_initgroups($username, $userinfo['gid'])) &&
+ posix_seteuid($userinfo['uid'])) {
$function($params);
}
posix_setegid($saved_egid);
posix_seteuid($saved_euid);
+ if ($saved_euid == 0)
+ posix_initgroups("root", 0);
}
// Local Variables: