*
* @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) {
+ function create($forum_name,$description,$send_all_posts_to='',$create_default_message=1) {
if (strlen($forum_name) < 3) {
$this->setError(_('Forum Name Must Be At Least 3 Characters'));
return false;
}
db_begin();
- $result = db_query_params('INSERT INTO forum_group_list (group_id,forum_name,is_public,description,send_all_posts_to,allow_anonymous,moderation_level) VALUES ($1,$2,$3,$4,$5,$6,$7)',
+ $result = db_query_params('INSERT INTO forum_group_list (group_id,forum_name,description,send_all_posts_to) VALUES ($1,$2,$3,$4)',
array($this->Group->getID(),
strtolower($forum_name),
- $is_public,
htmlspecialchars($description),
- $send_all_posts_to,
- $allow_anonymous,
- $moderation_level));
+ $send_all_posts_to));
if (!$result) {
$this->setError(_('Error Adding Forum:').' '.db_error());
db_rollback();
}
}
- /**
- * allowAnonymous - does this forum allow non-logged in users to post.
- *
- * @return boolean allow_anonymous.
- */
- function allowAnonymous() {
- return $this->data_array['allow_anonymous'];
- }
-
- /**
- * isPublic - Is this forum open to the general public.
- *
- * @return boolean is_public.
- */
- function isPublic() {
- return $this->data_array['is_public'];
- }
-
/**
* getName - get the name of this forum.
*
return $this->data_array['description'];
}
- /**
- * getModerationLevel - the moderation level of the forum
- *
- * @return int The moderation level.
- */
- function getModerationLevel() {
- return $this->data_array['moderation_level'];
- }
-
/**
* getMessageCount - the total number of messages in this forum.
*
*
* @param string The name of the forum.
* @param string The description of the forum.
- * @param int if it should be public (0) for private.
- * @param int if we should allow non-logged-in users to post (0) for mandatory login.
* @param string The email address to send all new posts to.
- * @param int 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 update($forum_name, $description, $allow_anonymous, $is_public, $send_all_posts_to = '', $moderation_level = 0) {
+ function update($forum_name, $description, $send_all_posts_to = '') {
if (strlen($forum_name) < 3) {
$this->setError(_('Forum Name Must Be At Least 3 Characters'));
return false;
$res = db_query_params('UPDATE forum_group_list SET
forum_name=$1,
description=$2,
- send_all_posts_to=$3,
- allow_anonymous=$4,
- moderation_level=$5,
- is_public=$6
- WHERE group_id=$7
- AND group_forum_id=$8',
+ send_all_posts_to=$3
+ WHERE group_id=$4
+ AND group_forum_id=$5',
array(strtolower($forum_name),
htmlspecialchars($description),
$send_all_posts_to,
- $allow_anonymous,
- $moderation_level,
- $is_public,
$this->Group->getID(),
$this->getID()));
session_require_perm ('forum_admin', $f->Group->getID()) ;
- if (!$f->update($forum_name,$description,0,0,$send_all_posts_to,0)) {
+ if (!$f->update($forum_name,$description,$send_all_posts_to)) {
exit_error($f->getErrorMessage(),'forums');
} else {
$feedback = _('Forum Info Updated Successfully');
form_release_key(getStringFromRequest("form_key"));
exit_error($f->getErrorMessage(),'forums');
}
- if (!$f->create($forum_name,$description,0,$send_all_posts_to,1,0,0)) {
+ if (!$f->create($forum_name,$description,$send_all_posts_to,1)) {
form_release_key(getStringFromRequest("form_key"));
exit_error($f->getErrorMessage(),'forums');
} else {
if ($project->usesForum()) {
echo '<div class="public-area-box">'."\n";
// print '<hr size="1" /><a rel="sioc:container_of" href="'.util_make_url ('/forum/?group_id='.$group_id).'">';
+ $ff = new ForumFactory($project);
+ $f_arr = $ff->getForums();
+ $forums_count = count($f_arr);
+ $messages_count = 0;
+ foreach ($f_arr as $f) {
+ $messages_count += $f->getMessageCount();
+ }
+
$link_content = $HTML->getForumPic('') . ' ' . _('Public Forums');
echo util_make_link ( '/forum/?group_id=' . $group_id, $link_content);
print ' (';
- $messages_count = project_get_public_forum_message_count($group_id);
- $forums_count = project_get_public_forum_count($group_id);
- printf(ngettext("<strong>%d</strong> message","<strong>%d</strong> messages",$messages_count),$messages_count);
- print ' in ';
- printf(ngettext("<strong>%d</strong> forum","<strong>%d</strong> forums",$forums_count),$forums_count);
- print ')' ;
- print "\n</div>";
- }
+ printf(ngettext("<strong>%d</strong> message","<strong>%d</strong> messages",$messages_count),$messages_count);
+ print ' in ';
+ printf(ngettext("<strong>%d</strong> forum","<strong>%d</strong> forums",$forums_count),$forums_count);
+ print ')' ;
+ print "\n</div>";
+ }
// ##################### Doc Manager
END ;
$$ LANGUAGE plpgsql ;
-SELECT migrate_tracker_allow_anon_to_rbac ();
+SELECT tmp_migrate_tracker_allow_anon_to_rbac ();
DROP FUNCTION tmp_migrate_tracker_allow_anon_to_rbac () ;
CREATE VIEW forum_group_list_vw AS
SELECT forum_group_list.group_forum_id, forum_group_list.group_id, forum_group_list.forum_name, forum_group_list.description, forum_group_list.send_all_posts_to, forum_agg_msg_count.count AS total, (SELECT max(forum.post_date) AS recent FROM forum WHERE (forum.group_forum_id = forum_group_list.group_forum_id)) AS recent, (SELECT count(*) AS count FROM (SELECT forum.thread_id FROM forum WHERE (forum.group_forum_id = forum_group_list.group_forum_id) GROUP BY forum.thread_id) tmp) AS threads FROM (forum_group_list LEFT JOIN forum_agg_msg_count USING (group_forum_id));
+DROP TRIGGER IF EXISTS fmsg_agg_trig ON forum;
+DROP TRIGGER IF EXISTS fora_agg_trig ON forum_group_list;
+
+CREATE OR REPLACE FUNCTION project_sums () RETURNS TRIGGER AS $$
+DECLARE
+ num integer;
+ curr_group integer;
+ found integer;
+BEGIN
+ ---
+ --- Get number of things this group has now
+ ---
+ IF TG_ARGV[0]='surv' THEN
+ IF TG_OP='DELETE' THEN
+ SELECT INTO num count(*) FROM surveys WHERE OLD.group_id=group_id AND is_active=1;
+ curr_group := OLD.group_id;
+ ELSE
+ SELECT INTO num count(*) FROM surveys WHERE NEW.group_id=group_id AND is_active=1;
+ curr_group := NEW.group_id;
+ END IF;
+ END IF;
+ IF TG_ARGV[0]='mail' THEN
+ IF TG_OP='DELETE' THEN
+ SELECT INTO num count(*) FROM mail_group_list WHERE OLD.group_id=group_id AND is_public=1;
+ curr_group := OLD.group_id;
+ ELSE
+ SELECT INTO num count(*) FROM mail_group_list WHERE NEW.group_id=group_id AND is_public=1;
+ curr_group := NEW.group_id;
+ END IF;
+ END IF;
+ ---
+ --- See if this group already has a row in project_sums_agg for these things
+ ---
+ SELECT INTO found count(group_id) FROM project_sums_agg WHERE curr_group=group_id AND type=TG_ARGV[0];
+
+ IF found=0 THEN
+ ---
+ --- Create row for this group
+ ---
+ INSERT INTO project_sums_agg
+ VALUES (curr_group, TG_ARGV[0], num);
+ ELSE
+ ---
+ --- Update count
+ ---
+ UPDATE project_sums_agg SET count=num
+ WHERE curr_group=group_id AND type=TG_ARGV[0];
+ END IF;
+
+ IF TG_OP='DELETE' THEN
+ RETURN OLD;
+ ELSE
+ RETURN NEW;
+ END IF;
+END;
+$$ LANGUAGE plpgsql;
+DELETE FROM project_sums_agg WHERE type='fora' OR type='fmsg';
+
ALTER TABLE forum_group_list DROP COLUMN is_public;
ALTER TABLE forum_group_list DROP COLUMN allow_anonymous;
ALTER TABLE forum_group_list DROP COLUMN moderation_level;
*
*/
- //create a pop-up select box listing the forums for this project
- //determine if this person can see private forums or not
- if (session_loggedin() && user_ismember($group_id)) {
- $public_flag='0,1';
- } else {
- $public_flag='1';
- }
-
//create a pop-up select box showing options for viewing threads
$vals=array('nested','flat','threaded','ultimate');
return project_getaggvalue($group_id,'surv');
}
-/**
- * project_get_public_forum_count() - Get the number of public forums for a project.
- *
- * @param int The group ID
- */
-function project_get_public_forum_count($group_id) {
- return project_getaggvalue($group_id, 'fora');
-}
-
-/**
- * project_get_public_forum_message_count() - Get the number of messages within public forums for a project.
- *
- * @param int The group ID
- */
-function project_get_public_forum_message_count($group_id) {
- return project_getaggvalue($group_id, 'fmsg');
-}
-
/**
* project_summary() - Build a project summary box that projects can insert into their project pages
*
$return .= html_image("ic/forum20g.png","20","20",array("alt"=>"Forums"));
$return .= ' Forums</a>';
+ $ff = new ForumFactory($project);
+ $f_arr = $ff->getForums();
+ $forums_count = count($f_arr);
+ $messages_count = 0;
+ foreach ($f_arr as $f) {
+ $messages_count += $f->getMessageCount();
+ }
+
if ($mode != 'compact') {
- $return .= " ( <strong>". project_get_public_forum_message_count($group_id) ."</strong> messages in ";
- $return .= "<strong>". project_get_public_forum_count($group_id) ."</strong> forums )\n";
+ $return .= sprintf(ngettext("<strong>%d</strong> message","<strong>%d</strong> messages",$messages_count),$messages_count);
+ $return .= ' in ';
+ $return .= sprintf(ngettext("<strong>%d</strong> forum","<strong>%d</strong> forums",$forums_count),$forums_count);
+ $return .= "\n";
}
}