Commit f54e27be authored by lrargerich's avatar lrargerich

Password protected forums. Topic level only or topic and threads

(selectable per forum).
User "level" added based in number of posts. (needs testing)
parent 6891dd3f
This diff is collapsed.
......@@ -130,9 +130,10 @@ class Comments extends TikiLib {
$show_description,
$inbound_address,$outbound_address,
$topic_smileys, $topic_summary,
$ui_avatar, $ui_flag, $ui_posts, $ui_email, $ui_online,
$ui_avatar, $ui_flag, $ui_posts, $ui_level,$ui_email, $ui_online,
$approval_type,
$moderator_group)
$moderator_group,
$forum_password, $forum_use_password)
{
$name = addslashes($name);
$moderator_group = addslashes($moderator_group);
......@@ -165,10 +166,13 @@ class Comments extends TikiLib {
ui_avatar = '$ui_avatar',
ui_flag = '$ui_flag',
ui_posts = '$ui_posts',
ui_level = '$ui_level',
ui_email = '$ui_email',
ui_online = '$ui_online',
approval_type = '$approval_type',
moderator_group = '$moderator_group',
forum_password = '$forum_password',
forum_use_password = '$forum_use_password',
topics_list_pts = '$topics_list_pts',
topics_list_lastpost = '$topics_list_lastpost',
topics_list_author = '$topics_list_author',
......@@ -186,7 +190,7 @@ class Comments extends TikiLib {
topics_list_reads,topics_list_replies,topics_list_pts,topics_list_lastpost,topics_list_author,vote_threads,show_description,
inbound_address,outbound_address,
topic_smileys,topic_summary,
ui_avatar,ui_flag,ui_posts,ui_email,ui_online,approval_type,moderator_group)
ui_avatar,ui_flag,ui_posts,ui_level,ui_email,ui_online,approval_type,moderator_group,forum_password,forum_use_password)
values ('$name','$description',$now,$now,0,
0,'$controlFlood',$floodInterval,'$moderator',0,'$mail','$useMail','$usePruneUnreplied',
$pruneUnrepliedAge, '$usePruneOld',
......@@ -195,7 +199,7 @@ class Comments extends TikiLib {
'$topics_list_reads','$topics_list_replies','$topics_list_pts','$topics_list_lastpost','$topics_list_author','$vote_threads','$show_description',
'$inbound_address','$outbound_address',
'$topic_smileys','$topic_summary',
'$ui_avatar','$ui_flag','$ui_posts','$ui_email','$ui_online','$approval_type','$moderator_group') ";
'$ui_avatar','$ui_flag','$ui_posts','$ui_level','$ui_email','$ui_online','$approval_type','$moderator_group','$forum_password','$forum_use_password') ";
$result = $this->query($query);
$forumId=$this->getOne("select max(forumId) from tiki_forums where name='$name' and created=$now");
}
......@@ -443,6 +447,7 @@ class Comments extends TikiLib {
$res["parsed"] = $this->parse_comment_data($res["data"]);
$res['user_posts']=$this->getOne("select posts from tiki_user_postings where user='".$res['userName']."'");
$res['user_level']=$this->getOne("select level from tiki_user_postings where user='".$res['userName']."'");
if($this->get_user_preference($res['userName'],'email is public','n')=='y') {
$res['user_email']=$this->getOne("select email from users_users where login='".$res['userName']."'");
......@@ -577,6 +582,7 @@ class Comments extends TikiLib {
// Get the last reply
$tid = $res["threadId"];
$res['user_posts']=$this->getOne("select posts from tiki_user_postings where user='".$res['userName']."'");
$res['user_level']=$this->getOne("select level from tiki_user_postings where user='".$res['userName']."'");
if($this->get_user_preference($res['userName'],'email is public','n')=='y') {
$res['user_email']=$this->getOne("select email from users_users where login='".$res['userName']."'");
} else {
......@@ -627,6 +633,7 @@ class Comments extends TikiLib {
// Get the last reply
$tid = $res["threadId"];
$res['user_posts']=$this->getOne("select posts from tiki_user_postings where user='".$res['userName']."'");
$res['user_level']=$this->getOne("select level from tiki_user_postings where user='".$res['userName']."'");
$res['user_email']=$this->getOne("select email from users_users where login='".$res['userName']."'");
$res['user_online']='n';
if($res['userName']) {
......@@ -772,7 +779,7 @@ class Comments extends TikiLib {
$level = 1;
}
$query = "update tiki_user_postins set level=$level where user='$userName'";
$query = "update tiki_user_postings set level=$level where user='$userName'";
$this->query($query);
}
......
......@@ -165,11 +165,11 @@ class TikiLib {
/*shared*/ function get_event_watches($event,$object)
{
$ret = Array();
$query = "select * from tiki_user_watches where event='$event' and object='$object'";
$result = $this->query($query);
if(!$result->numRows()) return false;
$ret = Array();
if(!$result->numRows()) return $ret;
while($res = $result->fetchRow(DB_FETCHMODE_ASSOC)) {
$ret[] = $res;
}
......
......@@ -44,6 +44,14 @@
{/section}
</select>
</td></tr>
<tr><td class="formcolor">{tr}Password protected{/tr}</td><td class="formcolor">
<select name="forum_use_password">
<option value="n" {if $forum_use_password eq 'n'}selected="selected"{/if}>{tr}No{/tr}</option>
<option value="t" {if $forum_use_password eq 't'}selected="selected"{/if}>{tr}Topics only{/tr}</option>
<option value="a" {if $forum_use_password eq 'a'}selected="selected"{/if}>{tr}All posts{/tr}</option>
</select>
</td></tr>
<tr><td class="formcolor">{tr}Forum password{/tr}</td><td class="formcolor"><input type="text" name="forum_password" value="{$forum_password}" /></td></tr>
{include file=categorize.tpl}
<tr><td class="formcolor">{tr}Default ordering for topics{/tr}:</td><td class="formcolor">
......@@ -141,6 +149,7 @@
<td>{tr}avatar{/tr}</td>
<td>{tr}flag{/tr}</td>
<td>{tr}posts{/tr}</td>
<td>{tr}user level{/tr}</td>
<td>{tr}email{/tr}</td>
<td>{tr}online{/tr}</td>
</tr>
......@@ -148,6 +157,7 @@
<td><input type="checkbox" name="ui_avatar" {if $ui_avatar eq 'y'}checked="checked"{/if} /></td>
<td><input type="checkbox" name="ui_flag" {if $ui_flag eq 'y'}checked="checked"{/if} /></td>
<td><input type="checkbox" name="ui_posts" {if $ui_posts eq 'y'}checked="checked"{/if} /></td>
<td><input type="checkbox" name="ui_level" {if $ui_level eq 'y'}checked="checked"{/if} /></td>
<td><input type="checkbox" name="ui_email" {if $ui_email eq 'y'}checked="checked"{/if} /></td>
<td><input type="checkbox" name="ui_online" {if $ui_online eq 'y'}checked="checked"{/if} /></td>
</tr>
......@@ -207,7 +217,7 @@
<td class="{cycle advance=false}">
{if ($tiki_p_admin eq 'y') or (($channels[user].individual eq 'n') and ($tiki_p_admin_forum eq 'y')) or ($channels[user].individual_tiki_p_admin_forum eq 'y')}
<a class="link" href="tiki-admin_forums.php?offset={$offset}&amp;sort_mode={$sort_mode}&amp;remove={$channels[user].forumId}"><img src='img/icons/trash.gif' alt='{tr}remove{/tr}' title='{tr}remove{/tr}' border='0' /></a>
<a class="link" href="tiki-admin_forums.php?offset={$offset}&amp;sort_mode={$sort_mode}&amp;forumId={$channels[user].forumId}"><img src='img/icons/edit.gif' alt='{tr}edit{/tr}' title='{tr}edit{/tr}' border='0' /></a>
<a class="link" href="tiki-admin_forums.php?offset={$offset}&amp;sort_mode={$sort_mode}&amp;forumId={$channels[user].forumId}"><img src='img/icons/config.gif' alt='{tr}edit{/tr}' title='{tr}edit{/tr}' border='0' /></a>
<a class="link" href="tiki-objectpermissions.php?objectName={tr}Forum{/tr}%20{$channels[user].name}&amp;objectType=forum&amp;permType=forums&amp;objectId={$channels[user].forumId}"><img src='img/icons/key.gif' border='0' alt='{tr}permissions{/tr}' title='{tr}permissions{/tr}' /></a>
{/if}
</td>
......
......@@ -103,7 +103,7 @@ a moderator approves it.{/tr}</small>
<td class="forumform">{tr}Title{/tr}</td>
<td class="forumform"><input type="text" name="comments_title" value="{$comment_title}" /></td>
{if $feature_smileys eq 'y'}<td rowspan="4" class="forumform">
{if $feature_smileys eq 'y'}<td rowspan="5" class="forumform">
<table>
<tr><td><a href="javascript:setSomeElement('editpost','(:biggrin:)');"><img src="img/smiles/icon_biggrin.gif" alt="big grin" border="0" /></a></td>
<td><a href="javascript:setSomeElement('editpost','(:confused:)');"><img src="img/smiles/icon_confused.gif" alt="confused" border="0" /></a></td>
......@@ -138,6 +138,14 @@ a moderator approves it.{/tr}</small>
</td>
{/if}
</tr>
{if $forum_info.forum_use_password ne 'n'}
<tr>
<td class='forumform'>{tr}Password{/tr}</td>
<td class='forumform'>
<input type="password" name="password" />
</td>
</tr>
{/if}
<tr>
<td class="forumform">{tr}Type{/tr}</td>
<td class="forumform">
......
......@@ -28,6 +28,9 @@ a moderator approves it.{/tr}</small>
{if $thread_info.userName and $forum_info.ui_posts eq 'y'}
<br/><small>posts:{$thread_info.user_posts}</small>
{/if}
{if $thread_info.userName and $forum_info.ui_level eq 'y'}
<br/><img src="img/icons/{$thread_info.user_level}stars.gif" alt='{$thread_info.user_level} {tr}stars{/tr}' title='{tr}user level{/tr}' />
{/if}
{if $thread_info.userName and $forum_info.ui_online eq 'y' and $thread_info.user_online eq 'y'}
<br/><small>now online</small>
{/if}
......@@ -152,7 +155,7 @@ a moderator approves it.{/tr}</small>
<td class="forumform">{tr}Title{/tr}</td>
<td class="forumform"><input type="text" name="comments_title" value="{$comment_title}" /></td>
{if $feature_smileys eq 'y'}
<td rowspan="2" class="forumform">
<td rowspan="3" class="forumform">
<table>
<tr><td><a href="javascript:setSomeElement('editpost','(:biggrin:)');"><img src="img/smiles/icon_biggrin.gif" alt="big grin" border="0" /></a></td>
<td><a href="javascript:setSomeElement('editpost','(:confused:)');"><img src="img/smiles/icon_confused.gif" alt="confused" border="0" /></a></td>
......@@ -188,6 +191,14 @@ a moderator approves it.{/tr}</small>
</td>
{/if}
</tr>
{if $forum_info.forum_use_password eq 'a'}
<tr>
<td class='forumform'>{tr}Password{/tr}</td>
<td class='forumform'>
<input type="password" name="password" />
</td>
</tr>
{/if}
<tr>
<td class="forumform">Comment</td>
<td class="forumform"><textarea id='editpost' name="comments_data" rows="8" cols="60">{$comment_data}</textarea></td>
......@@ -320,6 +331,9 @@ a moderator approves it.{/tr}</small>
{if $comments_coms[ix].userName and $forum_info.ui_posts eq 'y'}
<br/><small>posts:{$comments_coms[ix].user_posts}</small>
{/if}
{if $comments_coms[ix].userName and $forum_info.ui_level eq 'y'}
<br/><img src="img/icons/{$comments_coms[ix].user_level}stars.gif" alt='{$comments_coms[ix].user_level} {tr}stars{/tr}' title='{tr}user level{/tr}' />
{/if}
{if $comments_coms[ix].userName and $forum_info.ui_online eq 'y' and $comments_coms[ix].user_online eq 'y'}
<br/><small>now online</small>
{/if}
......
......@@ -70,10 +70,13 @@ if($_REQUEST["forumId"]) {
$info["ui_avatar"]='y';
$info["ui_flag"]='y';
$info["ui_posts"]='n';
$info['ui_level']='n';
$info["ui_email"]='n';
$info["ui_online"]='n';
$info["approval_type"]='all_posted';
$info["moderator_group"]='';
$info['forum_password']='';
$info['forum_use_password']='n';
$info["topics_list_reads"]='y';
$info["topics_list_pts"]='y';
......@@ -105,10 +108,13 @@ $smarty->assign('topic_summary',$info['topic_summary']);
$smarty->assign('ui_avatar',$info['ui_avatar']);
$smarty->assign('ui_flag',$info['ui_flag']);
$smarty->assign('ui_posts',$info['ui_posts']);
$smarty->assign('ui_level',$info['ui_level']);
$smarty->assign('ui_email',$info['ui_email']);
$smarty->assign('ui_online',$info['ui_online']);
$smarty->assign('approval_type',$info['approval_type']);
$smarty->assign('moderator_group',$info['moderator_group']);
$smarty->assign('forum_password',$info['forum_password']);
$smarty->assign('forum_use_password',$info['forum_use_password']);
$smarty->assign('topics_list_reads',$info['topics_list_reads']);
$smarty->assign('topics_list_pts',$info['topics_list_pts']);
......@@ -159,6 +165,7 @@ if(isset($_REQUEST["save"])) {
$_REQUEST['ui_flag']=isset($_REQUEST['ui_flag'])?'y':'n';
$_REQUEST['ui_email']=isset($_REQUEST['ui_email'])?'y':'n';
$_REQUEST['ui_posts']=isset($_REQUEST['ui_posts'])?'y':'n';
$_REQUEST['ui_level']=isset($_REQUEST['ui_level'])?'y':'n';
$_REQUEST['ui_online']=isset($_REQUEST['ui_online'])?'y':'n';
$_REQUEST['topics_list_pts']=isset($_REQUEST['topics_list_pts'])?'y':'n';
......@@ -168,7 +175,7 @@ if(isset($_REQUEST["save"])) {
if($_REQUEST["section"]=='__new__') $_REQUEST["section"]=$_REQUEST["new_section"];
$fid = $commentslib->replace_forum($_REQUEST["forumId"], $_REQUEST["name"], $_REQUEST["description"], $controlFlood,$_REQUEST["floodInterval"],$_REQUEST["moderator"], $_REQUEST["mail"], $useMail, $usePruneUnreplied, $_REQUEST["pruneUnrepliedAge"], $usePruneOld, $_REQUEST["pruneMaxAge"], $_REQUEST["topicsPerPage"], $_REQUEST["topicOrdering"], $_REQUEST["threadOrdering"], $_REQUEST["section"],$_REQUEST['topics_list_replies'],$_REQUEST['topics_list_reads'],$_REQUEST['topics_list_pts'],$_REQUEST['topics_list_lastpost'],$_REQUEST['topics_list_author'],$_REQUEST['vote_threads'],$_REQUEST['show_description'],
$_REQUEST['inbound_address'],$_REQUEST['outbound_address'],$_REQUEST['topic_smileys'],$_REQUEST['topic_summary'],$_REQUEST['ui_avatar'],$_REQUEST['ui_flag'],$_REQUEST['ui_posts'],$_REQUEST['ui_email'],$_REQUEST['ui_online'],$_REQUEST['approval_type'],$_REQUEST['moderator_group']);
$_REQUEST['inbound_address'],$_REQUEST['outbound_address'],$_REQUEST['topic_smileys'],$_REQUEST['topic_summary'],$_REQUEST['ui_avatar'],$_REQUEST['ui_flag'],$_REQUEST['ui_posts'],$_REQUEST['ui_level'],$_REQUEST['ui_email'],$_REQUEST['ui_online'],$_REQUEST['approval_type'],$_REQUEST['moderator_group'],$_REQUEST['forum_password'],$_REQUEST['forum_use_password']);
$cat_type='forum';
$cat_objid = $fid;
......@@ -201,10 +208,13 @@ if(isset($_REQUEST["save"])) {
$info["ui_avatar"]='y';
$info["ui_flag"]='y';
$info["ui_posts"]='n';
$info['ui_level']='n';
$info["ui_email"]='n';
$info["ui_online"]='n';
$info["approval_type"]='all_posted';
$info["moderator_group"]='';
$info['forum_password']='';
$info['forum_use_password']='n';
$info["topics_list_reads"]='y';
$info["topics_list_pts"]='y';
......@@ -240,10 +250,13 @@ if(isset($_REQUEST["save"])) {
$smarty->assign('ui_avatar',$info['ui_avatar']);
$smarty->assign('ui_flag',$info['ui_flag']);
$smarty->assign('ui_posts',$info['ui_posts']);
$smarty->assign('ui_level',$info['ui_level']);
$smarty->assign('ui_email',$info['ui_email']);
$smarty->assign('ui_online',$info['ui_online']);
$smarty->assign('approval_type',$info['approval_type']);
$smarty->assign('moderator_group',$info['moderator_group']);
$smarty->assign('forum_password',$info['forum_password']);
$smarty->assign('forum_use_password',$info['forum_password']);
}
......
......@@ -154,6 +154,13 @@ if($tiki_p_admin_forum == 'y' || $tiki_p_forum_post_topic == 'y') {
$_REQUEST["comment_topictype"]='n';
}
if($forum_info['forum_use_password'] != 'n' && $_REQUEST['password']!=$forum_info['forum_password']) {
$smarty->assign('msg',tra("Wrong password. Cannot post comment"));
$smarty->display("styles/$style_base/error.tpl");
die;
}
if( ($tiki_p_forum_autoapp != 'y') && ($forum_info['approval_type'] == 'queue_all' || (!$user && $forum_info['approval_type']=='queue_anon'))) {
$smarty->assign('was_queued','y');
$commentslib->replace_queue(0,$_REQUEST['forumId'],$comments_objectId,0,$user,$_REQUEST["comments_title"],$_REQUEST["comments_data"],$_REQUEST["comment_topictype"],$_REQUEST['comment_topicsmiley'],$_REQUEST["comment_topicsummary"],$_REQUEST["comments_title"]);
......@@ -171,7 +178,7 @@ if($tiki_p_admin_forum == 'y' || $tiki_p_forum_post_topic == 'y') {
}
// Check if the user is monitoring this post
if($feature_user_watches == 'y') {
$nots = $this->get_event_watches('forum_post_topic',$_REQUEST['forumId']);
$nots = $commentslib->get_event_watches('forum_post_topic',$_REQUEST['forumId']);
foreach($nots as $not) {
$smarty->assign('mail_forum',$forum_info["name"]);
$smarty->assign('mail_title',$_REQUEST["comments_title"]);
......
......@@ -123,6 +123,7 @@ if($tiki_p_admin_forum == 'y') {
$smarty->assign_by_ref('forum_info',$forum_info);
$thread_info = $commentslib->get_comment($_REQUEST["comments_parentId"]);
//print_r($thread_info);
$smarty->assign_by_ref('thread_info',$thread_info);
......@@ -161,6 +162,14 @@ if($tiki_p_admin_forum == 'y' || $tiki_p_forum_post == 'y') {
if($commentslib->user_can_post_to_forum($user, $_REQUEST["forumId"])) {
//Replace things between square brackets by links
$_REQUEST["comments_data"]=strip_tags($_REQUEST["comments_data"]);
if($forum_info['forum_use_password'] == 'a' && $_REQUEST['password']!=$forum_info['forum_password']) {
$smarty->assign('msg',tra("Wrong password. Cannot post comment"));
$smarty->display("styles/$style_base/error.tpl");
die;
}
if(($tiki_p_forum_autoapp != 'y') && ($forum_info['approval_type'] == 'queue_all' || (!$user && $forum_info['approval_type']=='queue_anon'))) {
$smarty->assign('was_queued','y');
$commentslib->replace_queue(0,$_REQUEST['forumId'],$comments_objectId,$_REQUEST["comments_parentId"],$user,$_REQUEST["comments_title"],$_REQUEST["comments_data"],'','','',$thread_info['title']);
......@@ -170,7 +179,7 @@ if($tiki_p_admin_forum == 'y' || $tiki_p_forum_post == 'y') {
$commentslib->post_new_comment($comments_objectId, $_REQUEST["comments_parentId"], $user, $_REQUEST["comments_title"], $_REQUEST["comments_data"]);
if($feature_user_watches == 'y') {
$nots = $this->get_event_watches('forum_post_thread',$_REQUEST['forumId']);
$nots = $commentslib->get_event_watches('forum_post_thread',$_REQUEST['forumId']);
foreach($nots as $not) {
$smarty->assign('mail_forum',$forum_info["name"]);
$smarty->assign('mail_title',$_REQUEST["comments_title"]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment