var $view_types;
/**
- * Constructor.
+ * Constructor.
*
- * @param object The Group object to which this forum is associated.
- * @param int The group_forum_id.
- * @param array The associative array of data.
- * @return boolean success.
+ * @param object The Group object to which this forum is associated.
+ * @param int The group_forum_id.
+ * @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'));
return false;
}
}
- $this->view_types[]='ultimate';
- $this->view_types[]='flat';
- $this->view_types[]='nested';
- $this->view_types[]='threaded';
+ $this->view_types[] = 'ultimate';
+ $this->view_types[] = 'flat';
+ $this->view_types[] = 'nested';
+ $this->view_types[] = 'threaded';
+ $this->is_news = $is_news;
return true;
}
/**
- * create - use this function to create a new entry in the database.
+ * create - use this function to create a new entry in the database.
*
- * @param string The name of the forum.
- * @param string The description of the forum.
- * @param int Pass (1) if it should be public (0) for private.
- * @param string The email address to send all new posts to.
- * @param int Pass (1) if a welcome message should be created (0) for no welcome message.
- * @param int Pass (1) if we should allow non-logged-in users to post (0) for mandatory login.
- * @param int Pass (0) if the messages that are posted in the forum should go to moderation before available. 0-> no moderation 1-> moderation for anonymous and non-project members 2-> moderation for everyone
- * @return boolean success.
+ * @param string The name of the forum.
+ * @param string The description of the forum.
+ * @param int Pass (1) if it should be public (0) for private.
+ * @param string The email address to send all new posts to.
+ * @param int Pass (1) if a welcome message should be created (0) for no welcome message.
+ * @param int Pass (1) if we should allow non-logged-in users to post (0) for mandatory login.
+ * @param int Pass (0) if the messages that are posted in the forum should go to moderation before available. 0-> no moderation 1-> moderation for anonymous and non-project members 2-> moderation for everyone
+ * @return boolean success.
*/
function create($forum_name,$description,$is_public=1,$send_all_posts_to='',$create_default_message=1,$allow_anonymous=1,$moderation_level=0) {
- 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;
}
class ForumAdmin extends Error {
var $group_id;
var $p,$g;
-
+
function ForumAdmin($group_id) {
- $this->group_id = $group_id;
+ $this->Error();
+ $this->group_id = $group_id;
if ($group_id) {
$this->group_id = $group_id;
$this->g = group_get_object($group_id);
$this->p =& $this->g->getPermission ();
+ if (!$this->g->usesForum()) {
+ $this->setError(sprintf(_('%s does not use the Forum tool'),
+ $this->g->getPublicName()));
+ return false;
+ }
}
}
-
+
/**
* PrintAdminMessageOptions - prints the different administrator options for a message
*
$new_sa['forum'] = array () ;
$new_pa['forum'] = array () ;
foreach ($projects as $p) {
+ if (!$p->usesForum()) {
+ continue;
+ }
$ff = new ForumFactory ($p) ;
- $fids = $ff->getAllForumIds () ;
+ $fids = $ff->getAllForumIdsWithNews () ;
foreach ($fids as $fid) {
- if (USE_PFO_RBAC) {
- if (array_key_exists ('forum', $this->perms_array)
- && array_key_exists ($fid, $this->perms_array['forum']) ) {
- $new_pa['forum'][$fid] = $this->perms_array['forum'][$fid] ;
- } elseif (array_key_exists ('new_forum', $this->perms_array)
- && array_key_exists ($p->getID(), $this->perms_array['new_forum']) ) {
- $new_pa['forum'][$fid] = $new_pa['new_forum'][$p->getID()] ;
- }
- } else {
- if (array_key_exists ('forum', $this->setting_array)
- && array_key_exists ($fid, $this->setting_array['forum']) ) {
- $new_sa['forum'][$fid] = $this->setting_array['forum'][$fid] ;
- } else {
- $new_sa['forum'][$fid] = $new_sa['newforum'][0] ;
- }
+ if (array_key_exists ('forum', $this->perms_array)
+ && array_key_exists ($fid, $this->perms_array['forum']) ) {
+ $new_pa['forum'][$fid] = $this->perms_array['forum'][$fid] ;
+ } elseif (array_key_exists ('new_forum', $this->perms_array)
+ && array_key_exists ($p->getID(), $this->perms_array['new_forum']) ) {
+ $new_pa['forum'][$fid] = $new_pa['new_forum'][$p->getID()] ;
}
}
}
create a new discussion forum without a default msg
if one isn't already there
*/
-
+
db_begin();
- $f = new Forum($group);
+ $f = new Forum($group, false, false, true);
if (!$f->create(preg_replace('/[^_\.0-9a-z-]/','-', strtolower($summary)),$details,1,'',0,0)) {
db_rollback();
exit_error($f->getErrorMessage(),'news');