* 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
* @param array The associative array of data.
* @return boolean success.
*/
- function Forum(&$Group, $group_forum_id = false, $arr = false) {
+ function Forum(&$Group, $group_forum_id=false, $arr=false, $is_news=false) {
$this->Error();
if (!$Group || !is_object($Group)) {
$this->setError(_('Forums: No Valid Group Object'));
$this->setError('Forums: '.$Group->getErrorMessage());
return false;
}
+ if (!$is_news && $group_forum_id) {
+ //
+ // Is this a news posting (or a real forum)?
+ //
+ $res = db_query_params('SELECT forum_id FROM news_bytes
+ WHERE forum_id=$1',
+ array($group_forum_id));
+ $is_news = $res && db_numrows($res) >= 1;
+ }
+ if (!$is_news && !$Group->usesForum()) {
+ $this->setError(sprintf(_('%s does not use the Forum tool'),
+ $Group->getPublicName()));
+ return false;
+ }
$this->Group =& $Group;
if ($group_forum_id) {
//
// Make sure they can even access this object
//
- if (!forge_check_perm ('forum', $this->getID(), 'read')) {
+ if (!$is_news &&
+ !forge_check_perm ('forum', $this->getID(), 'read')) {
$this->setPermissionDeniedError();
$this->data_array = null;
return false;
$this->view_types[] = 'flat';
$this->view_types[] = 'nested';
$this->view_types[] = 'threaded';
+ $this->is_news = $is_news;
return true;
}
* @return boolean success.
*/
function create($forum_name,$description,$send_all_posts_to='',$create_default_message=1) {
- if (strlen($forum_name) < 3) {
+ if (!$this->is_news && strlen($forum_name) < 3) {
$this->setError(_('Forum Name Must Be At Least 3 Characters'));
return false;
}
- if (strlen($description) < 10) {
+ if (!$this->is_news && strlen($description) < 10) {
$this->setError(_('Forum Description Must Be At Least 10 Characters'));
return false;
}
- if (!preg_match('/^([_\.0-9a-z-])*$/i',$forum_name)) {
- $this->setError(_('Illegal Characters in Forum Name'));
+ if (!preg_match('/^([_\.0-9a-z-])*$/i',$forum_name)) {
+ if (preg_match('/ /',$forum_name)){
+ $this->setError(_('Illegal Characters in Forum Name').' - '._('No space'));
+ }else{
+ $this->setError(_('Illegal Characters in Forum Name'));
+ }
return false;
}
if ($send_all_posts_to) {
return false;
}
if (!preg_match('/^([_\.0-9a-z-])*$/i',$forum_name)) {
- $this->setError(_('Illegal Characters in Forum Name'));
+ if (preg_match('/ /',$forum_name)){
+ $this->setError(_('Illegal Characters in Forum Name').' - '._('No space'));
+ }else{
+ $this->setError(_('Illegal Characters in Forum Name'));
+ }
return false;
}
if ($send_all_posts_to) {
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,
// mode: php
// c-file-style: "bsd"
// End:
-
-?>