Revision history for SuggestionsBoard


Revision [19235]

Last edited on 2008-01-28 00:14:44 by MartinRenvoize [Modified links pointing to docs server]

No Differences

Revision [17026]

Edited on 2007-05-31 23:27:48 by MartinRenvoize [Reverted]
Additions:
if ($val && $val!= '')
foreach($arr as $i=>$sug)
{
if ($sug['postby'] == $val) $res[] = $sug;
}
return $res;
else return $arr;
elseif ($func == 'replies')
function replies($a, $b)
//var_dump($add);
//var_dump($i);
static $add = true;
static $i = 0;

if ($a['replies']){}

$i += ($add) ? 1 : 0 ;
$add = false;

elseif ($func == 'status')
if ($val && $val!= '')
foreach($arr as $i=>$sug)
{
if ($sug['status'] == $val) $res[] = $sug;
}
return $res;
else return $arr;
else
return $arr;
** ------------------------------------------------------------------------------- DISPLAY ALL SUGGESTION TOPICS
if ($phase == 'manage_sugs')
$sug_arr = GetAllSuggestions($all_sugs);
$sort_get = (isset($_GET['sort'])) ? $_GET['sort'] : 'all';
$name_get = (isset($_GET['name'])) ? $_GET['name'] : 'all';
$status_get = (isset($_GET['status_sort'])) ? $_GET['status_sort'] : 'all';
$sort_get_up = ($_GET['sort_up']) ? ($_GET['sort_up']+0) : (1) ;
$parents = array();
if (!count($sug_arr) == 0)
foreach($sug_arr as $id => $data)
$cnt = array( 'replies' => (count($data)-1) );
$parents[] = $data[0] + $cnt;
$out = $this->Format("==== Suggestions Index ==== //This page contains all the ".( ($_GET['status_sort']!='all') ? GetStatusStr($_GET['status_sort']).' ' : ' ')."suggestions made ".( ($_GET['name'] != 'all' ) ? 'by '.$_GET['name'].' ' : '')."about this Wikka// ----");
// okie .. now we have the array holding the parent-suggestions ... lets make it happen ..
$out .= $this->FormOpen("","","get");
// Add New Suggestion Thread
if ( $this->HasAccess("comment") || $this->HasAccess("write") || $this->IsAdmin() )
{
$out .= "<a href=\"".$this->Href("","", "phase=add_sug")."\">Add Suggestion Thread</a>";
}
// Status Sorting ...
$out .= " | Show only ";
if ($status_get != 'all') { $st[GetStatusStr($status_get)] = 1;}
$out .= "\n\t\t\t<select name=\"status_sort\">";
$out .= "<option value=\"all\"".( ($status_get == 'all')?" selected":"").">Any</option>";
foreach($st as $msg=>$sta)
$out .= "\n\t\t\t\t<option value=\"".substr($msg, 0,1)."\"".(($sta==1) ? ' selected' : '').">$msg</option>";
$out .= "\n\t\t\t</select>";
// Search By Author
$out .= " suggested by ";
$out .= "";
$st = array();
$tot = 0;
foreach($this->LoadAll("SELECT id,postby FROM ".$this->config['table_prefix']."suggestions WHERE parent = '0'") as $idx => $data)
if ( ($st[$data['postby']]) || ($st[$data['postby']] > 1) )
$st[$data['postby']] += 1;
else
$st[$data['postby']] = 1;

$tot++;

$out .= "\n\t\t\t<select name=\"name\">";
$out .= "\n\t\t\t\t<option value=\"all\"".(($name_get=='all')?" selected":"").">Anyone ($tot)</option>";
foreach($st as $author => $count)
if (strlen($author) > 0)
$out .= "\n\t\t\t\t<option value=\"".$author."\"".(($name_get==$author)?" selected":"").">".$author." (".$count.")</option>";
$out .= "\n\t\t\t</select>";
$out .= "\n\t\t\t<input value=\" Go \" accesskey=\"g\" type=\"submit\"/>";
$out .= "\n\t\t".$this->FormClose()."\n\t\t<hr />";

// Created the topmost links bar ...
if ($sort_get != 'all')
// sort out the 'title' 'time' or 'postby'
if ( ($sort_get == 'title') || ($sort_get == 'time') || ($sort_get == 'status')) // TO FIX !!! //
{
$res = $this->LoadAll("SELECT * FROM ".$this->config['table_prefix']."suggestions WHERE parent = '0' ORDER BY ".$sort_get);
$parents = array();

foreach($res as $idx => $data)
{
if ($data['parent'] == 0)
{
$id = $data['id'];
$parents[$data['id']] = array();
}
else // handle the children...
{
$id = $data['parent'];
}
foreach($data as $i => $a)
{
$a = stripslashes($a);
}
$parents[$id][] = $data;
}
foreach($sug_arr as $idx => $info)
{
$cnt = array( 'replies' => (count($info)-1) );
foreach($parents as $i => $a)
{
if ($a[0]['id'] == $idx) $parents[$i] = array_merge($a[0] ,$cnt);
}
}

$parents = ($sort_get_up==1)? array_reverse($parents) :$parents ;
}
elseif ($sort_get == 'replies')
{
function repliesSB($a, $b)
{
if ($a["replies"]== $b["replies"]) return 0;
return ($a["replies"] > $b["replies"]) ? 1 : -1 ;
}
function repliesBS($a, $b)
{
if ($a["replies"]== $b["replies"]) return 0;
return ($a["replies"] < $b["replies"]) ? 1 : -1 ;
}
uasort($parents, "replies".(($sort_get_up==1)?"BS":"SB")) ;
}
elseif ($sort_get == 'postby')
{
function postbyBS($a, $b)
{
if ($a['postby'] == $b['postby']) return 0;
return ($a['postby'] < $b['postby']) ? -1 : 1;
}
function postbySB($a, $b)
{
if ($a['postby'] == $b['postby']) return 0;
return ($a['postby'] < $b['postby']) ? 1 : -1;
}
uasort($parents, 'postby'.(($sort_get_up==-1)?'BS':'SB'));
}
// The author filtering ...
if ($name_get !='all') {
$res = $parents;
$parents = array();
foreach($res as $i=>$info)
{
if ($info['postby'] === $name_get)
$parents[$i] = $info;
}
// The status filtering ...
if ($status_get !='all') {
$res = $parents;
$parents = array();
foreach($res as $i=>$info)
{
if ($info['status'] === $status_get)
$parents[$i] = $info;
}

// ------------- CREATING THE DISPLAY TABLE FROM $parents ARRAY...
$out .= "\n\t<table align=\"center\" width=\"90%\">";
$out .= "\n\t<tbody align=\"center\" bgcolor=\"#999999\">";
$out .= "\n\t\t<th>".((($_GET['sort_up']==1||$_GET['sort_up']==-1) && ($sort_get =='title') )? (($sort_get_up==-1)? "⇓" : "⇑"):'')."<a href=\"".$this->Href("","", "phase=manage_sugs&sort=title&sort_up=".(-$sort_get_up))."\">Topic</a></th>";
$out .= "\n\t\t<th>".((($_GET['sort_up']==1||$_GET['sort_up']==-1) && ($sort_get =='status') )? (($sort_get_up==-1)? "⇓" : "⇑"):'')."<a href=\"".$this->Href("","", "phase=manage_sugs&sort=status&sort_up=".(-$sort_get_up))."\">Status</a></th>";
$out .= "\n\t\t<th>".((($_GET['sort_up']==1||$_GET['sort_up']==-1) && ($sort_get =='postby') )? (($sort_get_up==-1)? "⇓" : "⇑"):'')."<a href=\"".$this->Href("","", "phase=manage_sugs&sort=postby&sort_up=".(-$sort_get_up))."\">Author</a></th>";
$out .= "\n\t\t<th>".((($_GET['sort_up']==1||$_GET['sort_up']==-1) && ($sort_get =='time') )? (($sort_get_up==-1)? "⇓" : "⇑"):'')."<a href=\"".$this->Href("","", "phase=manage_sugs&sort=time&sort_up=".(-$sort_get_up))."\">Posted On</a></th>";
$out .= "\n\t\t<th>".((($_GET['sort_up']==1||$_GET['sort_up']==-1) && ($sort_get =='replies') )? (($sort_get_up==-1)? "⇓" : "⇑"):'')."<a href=\"".$this->Href("","", "phase=manage_sugs&sort=replies&sort_up=".(-$sort_get_up))."\">Replies</a></th>";
if ($this->IsAdmin($this->GetUser()))
$out .= "\n\t\t<th>Actions</th>";
$out .= "\n\t</tbody>\n\t";
if (count($parents) > 0)
foreach($parents as $i=>$data)
{
$out .= "\t<tr>";
$out .= "\n\t\t<td><a href=\"".$this->Href("","", "phase=show_sug&id=".$data['id'])."\">".$data['title']."</a></td>";
$out .= "\n\t\t<td>".GetStatusStr($data['status'])."</td>";
$out .= "\n\t\t<td>".$this->Format($data['postby'])."</td>";
$out .= "\n\t\t<td>".$data['time']."</td>";
$out .= "\n\t\t<td align=\"center\">".$data['replies']."</td>";
if ($this->IsAdmin($this->GetUser()))
{
$st = array( 'Rejected' => 0, 'Implemented' => 0, 'Pending' => 0);
$st[GetStatusStr($data['status'])] = 1;
$out .= "\n\t\t<td>";
$out .= "\n\t\t<form action=\"".$this->config["base_url"].$this->PageTitle().( ($this->config["rewrite_mode"]) ? "?" : "&")."\" method=\"get\">\n";
$out .= "\n\t\t\t<a href=\"".$this->Href("","","phase=del_sug&delid=".$data['id'])."\">Delete</a> |";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"wakka\" value=\"".$this->PageTitle()."\"/>";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"phase\" value=\"chng_status\"/>";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"t_id\" value=\"".$data['id']."\"/>";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"from_phase\" value=\"".$phase."\"/>";
$out .= "\n\t\t\tChange to <select name=\"sug_status\">";
foreach($st as $msg=>$sta)
{
$out .= "\n\t\t\t\t<option value=\"".substr($msg, 0,1)."\"".(($sta==1) ? ' selected' : '').">$msg</option>";
}
$out .= "\n\t\t\t</select>\n";
$out .= "\n\t\t\t<input type=\"submit\" value=\" Go \"/>";
$out .= "\n\t\t</form>";
}
$out .= "\n\t\t</tr>";
}
else
$out .= "</table>\n\t".$this->Format("--- @@//===No Matches===//@@ --- ");
else
$out = "<table><tr><td>No Suggestions yet ...</td>";
if ( $this->HasAccess("comment") || $this->HasAccess("write") || $this->IsAdmin() )
{
$out .="<tr><tr><td><a href=\"".$this->Href("","", "phase=add_sug")."\">Add Suggestion Thread</a>";
}
$out .="</td></tr></table>";
echo $this->ReturnSafeHTML($out);
** ------------------------------------------------------------------------------- DISPLAY A SUGGESTION THREAD
elseif ($phase == 'show_sug')
$id = $_GET['id']+0;
$sug_arr = GetAllSuggestions($all_sugs);
$sug_arr = $sug_arr[$id];
$st = array( 'Rejected' => 0, 'Implemented' => 0, 'Pending' => 0);
$st[GetStatusStr($sug_arr[0]['status'])] = 1;
$out = $this->Format("====".$sug_arr[0]['title']."==== //The proposed suggestion is ".GetStatusStr($sug_arr[0]['status'])."//");
$out .= "\n\t\t<form action=\"".$this->config["base_url"].$this->PageTitle().( ($this->config["rewrite_mode"]) ? "?" : "&")."\" method=\"get\">\n";
$out .= "<a href=\"".$this->Href("","", "phase=manage_sugs&sort=all\"").">Suggestions Index</a> | ";
$out .= "<a href=\"".$this->Href("","", "&phase=add_sug\"").">New Suggestion</a> | ";
$out .= "\n\t\t\t<a href=\"".$this->Href("","","phase=del_sug&delid=".$id)."\">Delete This Suggestion Thread</a> |";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"wakka\" value=\"".$this->PageTitle()."\"/>";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"phase\" value=\"chng_status\"/>";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"t_id\" value=\"".$sug_arr[0]['id']."\"/>";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"from_phase\" value=\"".$phase."\"/>";
$out .= "\n\t\t\tChange Status to <select name=\"sug_status\">";
foreach($st as $msg=>$sta)
$out .= "\n\t\t\t\t<option value=\"".substr($msg, 0,1)."\"".(($sta==1) ? ' selected' : '').">$msg</option>";
$out .= "\n\t\t\t</select>\n";
$out .= "\n\t\t\t<input type=\"submit\" value=\" Go \"/>";
$out .= "\n\t\t</form>";
$out.= $this->Format("----");
foreach($sug_arr as $i => $data)
$out .= "\n<table width=\"100%\">";
$out .= "\n\t<tr>\n\t\t<td colspan=\"2\">".($this->Format("**".$data['title']."**"));
// if this is the owner and this isnt a first suggestion , or this is an admin .. then add a delete button ...
if (!$data['parent']==0)
if ( ($this->GetUserName() == $data['postby']) || ($this->IsAdmin($this->GetUser())) )
{
$out .= " | <small><a href=\"".$this->Href("","", "&phase=del_sug&id=".$id."&delid=".$data['id'])."&title=".htmlspecialchars($data['title'])."\">Delete</a></small>";
}
}
$out .= "\n\t\t</td>\n\t</tr>";
$out .= "\n\t<tr>\n\t\t<td bgcolor=\"#999999\" width=\"5%\"></td>\n\t\t<td>".($this->Format($data['content']))."</td>\n\t</tr>";
// do the final row on this particular suggestion entry ...
$out .= "\n\t<tr>\n\t\t<td colspan=\"2\"><small>".($this->Format("//".$data['postby']." posted on ".$data['time']."//"))."</small></td>\n\t</tr>";
$out .= "\n</table>\n<hr />";
if ( ( ($this->HasAccess("comment")) && ($this->HasAccess("write")) )|| $this->IsAdmin())
$out .= "<form action=\"".$this->Href("","", "phase=reply_to&id=".$id)."\" method=\"post\">\n";
$out .= "<input type=\"hidden\" name=\"status\" value=\"".$data['status']."\">";
$out .= "\n\tTopic : <br /><textarea id=\"topic_text\" name=\"topic\" cols=\"78\"></textarea><br />";

$out .= "\n\t<label for=\"reply_text\">Add a reply to this suggestion :<br />\n\t\t";
$out .= "\n\t\t<textarea id=\"reply_text\" name=\"body\" rows=\"6\" cols=\"78\"></textarea>";
$out .= "\n\t</label><br />";

$out .= "\n\t\t<br /><small>When you are ready to submit your Reply you may press ".$this->Format("#%Alt#%+#%A#%")." or <input value=\"Add Reply\" accesskey=\"a\" type=\"submit\"/>\n\t";
$out .= $this->FormClose();
echo $this->ReturnSafeHTML($out);
** ------------------------------------------------------------------------------- DELETE REPLY
elseif ($phase == 'del_sug')
if ( isset($_GET['delid']) && ($_GET['delid'] != "") )
if ( ($this->GetUserName() == $data['postby']) || ($this->IsAdmin($this->GetUser())) )
$delid = $_GET['delid'];
$parent_id = $_GET['id'];
if ( ($delid == $parent_id) && ($this->IsAdmin($this->GetUser())) )
{
$msg = "The thread entitled : ".$_GET['title']." was deleted";
$url = "&phase=show_sug&id=".$parent_id;
}
else
{
$msg = "The reply to the ".( (isset($_GET['title'])) ? $_GET['title'] : 'suggestion')." was deleted.";
$url = "phase=manage_sugs";
}
$this->Query("DELETE FROM ".$this->config["table_prefix"]."suggestions WHERE (id = '".$delid."' or parent='".$delid."')");
$this->SetMessage($msg);
$this->Redirect($this->Href("","", $url));
else
$this->Redirect($this->Href("","", "&phase=show_sug&id=".$_GET['id']));
** ------------------------------------------------------------------------------- REPLY TO SUGGESTION
elseif ($phase == 'reply_to')
if ( ( ($this->HasAccess("comment")) && ($this->HasAccess("write")) )|| $this->IsAdmin())
{
if (($_POST['status'] != "I") && ($_POST['status'] != "R"))
{
$this->Query("INSERT INTO ".$this->config["table_prefix"]."suggestions (title,postby,time,status,content,parent) ".
"VALUES ('".addslashes($_POST['topic'])."', '".($this->GetUserName())."', NOW(), '".$_POST['status']."', '".addslashes($_POST['body'])."', '".$_GET['id']."')");
$this->SetMessage("The reply to the \"".( (isset($_GET['title'])) ? $_GET['title'] : 'suggestion')."\" was added." );
$this->Redirect($this->Href("","", "&phase=show_sug&id=".$_GET['id']));
}
else
{
$this->SetMessage("You can't add replies to this suggestion. Its status is set to ".GetStatusStr($sug_arr['status']));
$this->Redirect($this->Href("","", "&phase=show_sug&id=".$_GET['id']));
}
}
else
{
$this->SetMessage("You can't add replies to this suggestion, you dont have the proper privileges.");
$this->Redirect($this->Href("","", "&phase=show_sug&id=".$_GET['id']));
** ------------------------------------------------------------------------------- ADD NEW SUGGESTION THREAD
elseif ($phase == 'add_sug')
if ( ( ($this->HasAccess("comment")) && ($this->HasAccess("write")) )|| $this->IsAdmin())
if (!isset($_GET['done']))
$out = $this->Format("@@===New Suggestion===@@");
$out .= "<a href=\"".$this->Href("","", "phase=manage_sugs&sort=all")."\">Suggestions Index</a>";
$out .= $this->Format(">>Minimum **Topic** length is set to ".$min_topic_length." character".(($min_topic_length == 1)? '' : 's')." --- Minimum **Reply** length is set to ".$min_reply_length." character".(($min_reply_length == 1)? '' : 's').">>--- ----");
$out .= "<form action=\"".$this->Href("","", "phase=add_sug&done=1")."\" method=\"post\">\n";
$out .= "\n\tTopic : <br /><textarea id=\"topic_text\" name=\"topic\" cols=\"60\"></textarea><br />";
$out .= "\n\t<label for=\"reply_text\">Add a reply to this suggestion :<br />\n\t\t";
$out .= "\n\t\t<textarea id=\"reply_text\" name=\"body_text\" rows=\"8\" cols=\"60\"></textarea>";
$out .= "\n\t</label><br />";
$out .= "\n\t\t<br /><small>When you are ready to submit your Reply you may press ".$this->Format("#%Alt#%+#%A#%")." or <input value=\"Add New Suggestion\" accesskey=\"a\" type=\"submit\"></small>\n\t";
$out .= $this->FormClose();
echo $this->ReturnSafeHTML($out);
else
if (isset($_GET['done']) )// if the Add Reply was pressed then
{ // check if the lengths of the inputs are ok ...
$_GET['done'] = ( (strlen($_POST['topic']) >= $min_topic_length)&&(strlen($_POST['body_text']) >= $min_reply_length) )? 1 : -1;
}
else // if we reached here from smwh else than the Add Reply Button. .. (possibly a $this->Redirect)
{
$_GET['done'] = 0;
}
switch($_GET['done'])
{
case 1:
$this->Query("INSERT INTO ".$this->config['table_prefix']."suggestions( `title` , `postby` , `time` , `content` , `parent` )
VALUES ( '".addslashes($_POST['topic'])."', '".($this->GetUserName())."', now( ) , '".addslashes($_POST['body_text'])."', 0)");
$_GET['done'] = 0;
$this->SetMessage("New Suggestion Posted");
$this->Redirect($this->Href("","", "phase=manage_sug"));
break;
case -1:
$msg = "The Suggestion Topic has to be more than ".$min_topic_length." character".(($min_topic_length == 1 )?'s' : '')." long and ";
$msg .= "the Suggestion Text has to be more than ".$min_reply_length." character".(($min_reply_length == 1 )?'s' : '')." long.";
$this->SetMessage($msg);
$this->Redirect($this->Href("","", "&phase=add_sug"));
break;
default:
$this->Redirect($this->Href("","", "&phase=add_sug"));
}
** ------------------------------------------------------------------------------- CHANGE STATUS TO A SUGGESTION THREAD
elseif ($phase == 'chng_status')
if ( ($this->IsAdmin()) && ($_GET['t_id'] !== 0) )
$this->Query("UPDATE ".$this->config['table_prefix']."suggestions SET status='".$_GET['sug_status']."' where id=".$_GET['t_id']." or parent=".$_GET['t_id']);
$this->SetMessage("The status of ".GetTitleFromID($_GET['t_id'], $all_sugs)." is now set to ".GetStatusStr($_GET['sug_status']));
$this->Redirect($this->Href("","",( ($_GET['from_phase']=='show_sug') ? "&phase=".$_GET['from_phase']."&id=".$_GET['t_id'] : "phase=".$_GET['from_phase'] ) ));
else // silently redirect to the Suggestions Index ...
$this->Redirect($this-Href("","","phase=manage_sugs"));
?>
%%
===Usage===
You just insert ""{{msgboard}}"" inside any page. Keep in mind that posting on this is affected by the ACLS of the specific page.
===Final Note===
This is my Gift to the Wikka development to enable these wonderfull people behind Wikka to manage the Suggestions they receive ...
Happy New Year to All ;)
----//Suggestions, Modifications as well as comments are most welcome ...//----
Happy New Year to all!
- ++See my comment below for the missing "create entry function"++ I added a little bit to the code above. It should be possible now to add new topics if there are none
- I added a ".$this->config["table_prefix"]." to the first query
- changing the status of a topic does not work with mod_rewrite
- I like this modification very much :) --NilsLindenberg
----
CategoryUserContributions
Deletions:
if ($val


Revision [16825]

Edited on 2007-05-31 10:51:42 by Je3Ffz [Reverted]
Additions:
if ($val
Deletions:
if ($val && $val!= '')
foreach($arr as $i=>$sug)
{
if ($sug['postby'] == $val) $res[] = $sug;
}
return $res;
else return $arr;
elseif ($func == 'replies')
function replies($a, $b)
//var_dump($add);
//var_dump($i);
static $add = true;
static $i = 0;

if ($a['replies']){}

$i += ($add) ? 1 : 0 ;
$add = false;

elseif ($func == 'status')
if ($val && $val!= '')
foreach($arr as $i=>$sug)
{
if ($sug['status'] == $val) $res[] = $sug;
}
return $res;
else return $arr;
else
return $arr;
** ------------------------------------------------------------------------------- DISPLAY ALL SUGGESTION TOPICS
if ($phase == 'manage_sugs')
$sug_arr = GetAllSuggestions($all_sugs);
$sort_get = (isset($_GET['sort'])) ? $_GET['sort'] : 'all';
$name_get = (isset($_GET['name'])) ? $_GET['name'] : 'all';
$status_get = (isset($_GET['status_sort'])) ? $_GET['status_sort'] : 'all';
$sort_get_up = ($_GET['sort_up']) ? ($_GET['sort_up']+0) : (1) ;
$parents = array();
if (!count($sug_arr) == 0)
foreach($sug_arr as $id => $data)
$cnt = array( 'replies' => (count($data)-1) );
$parents[] = $data[0] + $cnt;
$out = $this->Format("==== Suggestions Index ==== //This page contains all the ".( ($_GET['status_sort']!='all') ? GetStatusStr($_GET['status_sort']).' ' : ' ')."suggestions made ".( ($_GET['name'] != 'all' ) ? 'by '.$_GET['name'].' ' : '')."about this Wikka// ----");
// okie .. now we have the array holding the parent-suggestions ... lets make it happen ..
$out .= $this->FormOpen("","","get");
// Add New Suggestion Thread
if ( $this->HasAccess("comment") || $this->HasAccess("write") || $this->IsAdmin() )
{
$out .= "<a href=\"".$this->Href("","", "phase=add_sug")."\">Add Suggestion Thread</a>";
}
// Status Sorting ...
$out .= " | Show only ";
if ($status_get != 'all') { $st[GetStatusStr($status_get)] = 1;}
$out .= "\n\t\t\t<select name=\"status_sort\">";
$out .= "<option value=\"all\"".( ($status_get == 'all')?" selected":"").">Any</option>";
foreach($st as $msg=>$sta)
$out .= "\n\t\t\t\t<option value=\"".substr($msg, 0,1)."\"".(($sta==1) ? ' selected' : '').">$msg</option>";
$out .= "\n\t\t\t</select>";
// Search By Author
$out .= " suggested by ";
$out .= "";
$st = array();
$tot = 0;
foreach($this->LoadAll("SELECT id,postby FROM ".$this->config['table_prefix']."suggestions WHERE parent = '0'") as $idx => $data)
if ( ($st[$data['postby']]) || ($st[$data['postby']] > 1) )
$st[$data['postby']] += 1;
else
$st[$data['postby']] = 1;

$tot++;

$out .= "\n\t\t\t<select name=\"name\">";
$out .= "\n\t\t\t\t<option value=\"all\"".(($name_get=='all')?" selected":"").">Anyone ($tot)</option>";
foreach($st as $author => $count)
if (strlen($author) > 0)
$out .= "\n\t\t\t\t<option value=\"".$author."\"".(($name_get==$author)?" selected":"").">".$author." (".$count.")</option>";
$out .= "\n\t\t\t</select>";
$out .= "\n\t\t\t<input value=\" Go \" accesskey=\"g\" type=\"submit\"/>";
$out .= "\n\t\t".$this->FormClose()."\n\t\t<hr />";

// Created the topmost links bar ...
if ($sort_get != 'all')
// sort out the 'title' 'time' or 'postby'
if ( ($sort_get == 'title') || ($sort_get == 'time') || ($sort_get == 'status')) // TO FIX !!! //
{
$res = $this->LoadAll("SELECT * FROM ".$this->config['table_prefix']."suggestions WHERE parent = '0' ORDER BY ".$sort_get);
$parents = array();

foreach($res as $idx => $data)
{
if ($data['parent'] == 0)
{
$id = $data['id'];
$parents[$data['id']] = array();
}
else // handle the children...
{
$id = $data['parent'];
}
foreach($data as $i => $a)
{
$a = stripslashes($a);
}
$parents[$id][] = $data;
}
foreach($sug_arr as $idx => $info)
{
$cnt = array( 'replies' => (count($info)-1) );
foreach($parents as $i => $a)
{
if ($a[0]['id'] == $idx) $parents[$i] = array_merge($a[0] ,$cnt);
}
}

$parents = ($sort_get_up==1)? array_reverse($parents) :$parents ;
}
elseif ($sort_get == 'replies')
{
function repliesSB($a, $b)
{
if ($a["replies"]== $b["replies"]) return 0;
return ($a["replies"] > $b["replies"]) ? 1 : -1 ;
}
function repliesBS($a, $b)
{
if ($a["replies"]== $b["replies"]) return 0;
return ($a["replies"] < $b["replies"]) ? 1 : -1 ;
}
uasort($parents, "replies".(($sort_get_up==1)?"BS":"SB")) ;
}
elseif ($sort_get == 'postby')
{
function postbyBS($a, $b)
{
if ($a['postby'] == $b['postby']) return 0;
return ($a['postby'] < $b['postby']) ? -1 : 1;
}
function postbySB($a, $b)
{
if ($a['postby'] == $b['postby']) return 0;
return ($a['postby'] < $b['postby']) ? 1 : -1;
}
uasort($parents, 'postby'.(($sort_get_up==-1)?'BS':'SB'));
}
// The author filtering ...
if ($name_get !='all') {
$res = $parents;
$parents = array();
foreach($res as $i=>$info)
{
if ($info['postby'] === $name_get)
$parents[$i] = $info;
}
// The status filtering ...
if ($status_get !='all') {
$res = $parents;
$parents = array();
foreach($res as $i=>$info)
{
if ($info['status'] === $status_get)
$parents[$i] = $info;
}

// ------------- CREATING THE DISPLAY TABLE FROM $parents ARRAY...
$out .= "\n\t<table align=\"center\" width=\"90%\">";
$out .= "\n\t<tbody align=\"center\" bgcolor=\"#999999\">";
$out .= "\n\t\t<th>".((($_GET['sort_up']==1||$_GET['sort_up']==-1) && ($sort_get =='title') )? (($sort_get_up==-1)? "⇓" : "⇑"):'')."<a href=\"".$this->Href("","", "phase=manage_sugs&sort=title&sort_up=".(-$sort_get_up))."\">Topic</a></th>";
$out .= "\n\t\t<th>".((($_GET['sort_up']==1||$_GET['sort_up']==-1) && ($sort_get =='status') )? (($sort_get_up==-1)? "⇓" : "⇑"):'')."<a href=\"".$this->Href("","", "phase=manage_sugs&sort=status&sort_up=".(-$sort_get_up))."\">Status</a></th>";
$out .= "\n\t\t<th>".((($_GET['sort_up']==1||$_GET['sort_up']==-1) && ($sort_get =='postby') )? (($sort_get_up==-1)? "⇓" : "⇑"):'')."<a href=\"".$this->Href("","", "phase=manage_sugs&sort=postby&sort_up=".(-$sort_get_up))."\">Author</a></th>";
$out .= "\n\t\t<th>".((($_GET['sort_up']==1||$_GET['sort_up']==-1) && ($sort_get =='time') )? (($sort_get_up==-1)? "⇓" : "⇑"):'')."<a href=\"".$this->Href("","", "phase=manage_sugs&sort=time&sort_up=".(-$sort_get_up))."\">Posted On</a></th>";
$out .= "\n\t\t<th>".((($_GET['sort_up']==1||$_GET['sort_up']==-1) && ($sort_get =='replies') )? (($sort_get_up==-1)? "⇓" : "⇑"):'')."<a href=\"".$this->Href("","", "phase=manage_sugs&sort=replies&sort_up=".(-$sort_get_up))."\">Replies</a></th>";
if ($this->IsAdmin($this->GetUser()))
$out .= "\n\t\t<th>Actions</th>";
$out .= "\n\t</tbody>\n\t";
if (count($parents) > 0)
foreach($parents as $i=>$data)
{
$out .= "\t<tr>";
$out .= "\n\t\t<td><a href=\"".$this->Href("","", "phase=show_sug&id=".$data['id'])."\">".$data['title']."</a></td>";
$out .= "\n\t\t<td>".GetStatusStr($data['status'])."</td>";
$out .= "\n\t\t<td>".$this->Format($data['postby'])."</td>";
$out .= "\n\t\t<td>".$data['time']."</td>";
$out .= "\n\t\t<td align=\"center\">".$data['replies']."</td>";
if ($this->IsAdmin($this->GetUser()))
{
$st = array( 'Rejected' => 0, 'Implemented' => 0, 'Pending' => 0);
$st[GetStatusStr($data['status'])] = 1;
$out .= "\n\t\t<td>";
$out .= "\n\t\t<form action=\"".$this->config["base_url"].$this->PageTitle().( ($this->config["rewrite_mode"]) ? "?" : "&")."\" method=\"get\">\n";
$out .= "\n\t\t\t<a href=\"".$this->Href("","","phase=del_sug&delid=".$data['id'])."\">Delete</a> |";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"wakka\" value=\"".$this->PageTitle()."\"/>";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"phase\" value=\"chng_status\"/>";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"t_id\" value=\"".$data['id']."\"/>";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"from_phase\" value=\"".$phase."\"/>";
$out .= "\n\t\t\tChange to <select name=\"sug_status\">";
foreach($st as $msg=>$sta)
{
$out .= "\n\t\t\t\t<option value=\"".substr($msg, 0,1)."\"".(($sta==1) ? ' selected' : '').">$msg</option>";
}
$out .= "\n\t\t\t</select>\n";
$out .= "\n\t\t\t<input type=\"submit\" value=\" Go \"/>";
$out .= "\n\t\t</form>";
}
$out .= "\n\t\t</tr>";
}
else
$out .= "</table>\n\t".$this->Format("--- @@//===No Matches===//@@ --- ");
else
$out = "<table><tr><td>No Suggestions yet ...</td>";
if ( $this->HasAccess("comment") || $this->HasAccess("write") || $this->IsAdmin() )
{
$out .="<tr><tr><td><a href=\"".$this->Href("","", "phase=add_sug")."\">Add Suggestion Thread</a>";
}
$out .="</td></tr></table>";
echo $this->ReturnSafeHTML($out);
** ------------------------------------------------------------------------------- DISPLAY A SUGGESTION THREAD
elseif ($phase == 'show_sug')
$id = $_GET['id']+0;
$sug_arr = GetAllSuggestions($all_sugs);
$sug_arr = $sug_arr[$id];
$st = array( 'Rejected' => 0, 'Implemented' => 0, 'Pending' => 0);
$st[GetStatusStr($sug_arr[0]['status'])] = 1;
$out = $this->Format("====".$sug_arr[0]['title']."==== //The proposed suggestion is ".GetStatusStr($sug_arr[0]['status'])."//");
$out .= "\n\t\t<form action=\"".$this->config["base_url"].$this->PageTitle().( ($this->config["rewrite_mode"]) ? "?" : "&")."\" method=\"get\">\n";
$out .= "<a href=\"".$this->Href("","", "phase=manage_sugs&sort=all\"").">Suggestions Index</a> | ";
$out .= "<a href=\"".$this->Href("","", "&phase=add_sug\"").">New Suggestion</a> | ";
$out .= "\n\t\t\t<a href=\"".$this->Href("","","phase=del_sug&delid=".$id)."\">Delete This Suggestion Thread</a> |";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"wakka\" value=\"".$this->PageTitle()."\"/>";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"phase\" value=\"chng_status\"/>";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"t_id\" value=\"".$sug_arr[0]['id']."\"/>";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"from_phase\" value=\"".$phase."\"/>";
$out .= "\n\t\t\tChange Status to <select name=\"sug_status\">";
foreach($st as $msg=>$sta)
$out .= "\n\t\t\t\t<option value=\"".substr($msg, 0,1)."\"".(($sta==1) ? ' selected' : '').">$msg</option>";
$out .= "\n\t\t\t</select>\n";
$out .= "\n\t\t\t<input type=\"submit\" value=\" Go \"/>";
$out .= "\n\t\t</form>";
$out.= $this->Format("----");
foreach($sug_arr as $i => $data)
$out .= "\n<table width=\"100%\">";
$out .= "\n\t<tr>\n\t\t<td colspan=\"2\">".($this->Format("**".$data['title']."**"));
// if this is the owner and this isnt a first suggestion , or this is an admin .. then add a delete button ...
if (!$data['parent']==0)
if ( ($this->GetUserName() == $data['postby']) || ($this->IsAdmin($this->GetUser())) )
{
$out .= " | <small><a href=\"".$this->Href("","", "&phase=del_sug&id=".$id."&delid=".$data['id'])."&title=".htmlspecialchars($data['title'])."\">Delete</a></small>";
}
}
$out .= "\n\t\t</td>\n\t</tr>";
$out .= "\n\t<tr>\n\t\t<td bgcolor=\"#999999\" width=\"5%\"></td>\n\t\t<td>".($this->Format($data['content']))."</td>\n\t</tr>";
// do the final row on this particular suggestion entry ...
$out .= "\n\t<tr>\n\t\t<td colspan=\"2\"><small>".($this->Format("//".$data['postby']." posted on ".$data['time']."//"))."</small></td>\n\t</tr>";
$out .= "\n</table>\n<hr />";
if ( ( ($this->HasAccess("comment")) && ($this->HasAccess("write")) )|| $this->IsAdmin())
$out .= "<form action=\"".$this->Href("","", "phase=reply_to&id=".$id)."\" method=\"post\">\n";
$out .= "<input type=\"hidden\" name=\"status\" value=\"".$data['status']."\">";
$out .= "\n\tTopic : <br /><textarea id=\"topic_text\" name=\"topic\" cols=\"78\"></textarea><br />";

$out .= "\n\t<label for=\"reply_text\">Add a reply to this suggestion :<br />\n\t\t";
$out .= "\n\t\t<textarea id=\"reply_text\" name=\"body\" rows=\"6\" cols=\"78\"></textarea>";
$out .= "\n\t</label><br />";

$out .= "\n\t\t<br /><small>When you are ready to submit your Reply you may press ".$this->Format("#%Alt#%+#%A#%")." or <input value=\"Add Reply\" accesskey=\"a\" type=\"submit\"/>\n\t";
$out .= $this->FormClose();
echo $this->ReturnSafeHTML($out);
** ------------------------------------------------------------------------------- DELETE REPLY
elseif ($phase == 'del_sug')
if ( isset($_GET['delid']) && ($_GET['delid'] != "") )
if ( ($this->GetUserName() == $data['postby']) || ($this->IsAdmin($this->GetUser())) )
$delid = $_GET['delid'];
$parent_id = $_GET['id'];
if ( ($delid == $parent_id) && ($this->IsAdmin($this->GetUser())) )
{
$msg = "The thread entitled : ".$_GET['title']." was deleted";
$url = "&phase=show_sug&id=".$parent_id;
}
else
{
$msg = "The reply to the ".( (isset($_GET['title'])) ? $_GET['title'] : 'suggestion')." was deleted.";
$url = "phase=manage_sugs";
}
$this->Query("DELETE FROM ".$this->config["table_prefix"]."suggestions WHERE (id = '".$delid."' or parent='".$delid."')");
$this->SetMessage($msg);
$this->Redirect($this->Href("","", $url));
else
$this->Redirect($this->Href("","", "&phase=show_sug&id=".$_GET['id']));
** ------------------------------------------------------------------------------- REPLY TO SUGGESTION
elseif ($phase == 'reply_to')
if ( ( ($this->HasAccess("comment")) && ($this->HasAccess("write")) )|| $this->IsAdmin())
{
if (($_POST['status'] != "I") && ($_POST['status'] != "R"))
{
$this->Query("INSERT INTO ".$this->config["table_prefix"]."suggestions (title,postby,time,status,content,parent) ".
"VALUES ('".addslashes($_POST['topic'])."', '".($this->GetUserName())."', NOW(), '".$_POST['status']."', '".addslashes($_POST['body'])."', '".$_GET['id']."')");
$this->SetMessage("The reply to the \"".( (isset($_GET['title'])) ? $_GET['title'] : 'suggestion')."\" was added." );
$this->Redirect($this->Href("","", "&phase=show_sug&id=".$_GET['id']));
}
else
{
$this->SetMessage("You can't add replies to this suggestion. Its status is set to ".GetStatusStr($sug_arr['status']));
$this->Redirect($this->Href("","", "&phase=show_sug&id=".$_GET['id']));
}
}
else
{
$this->SetMessage("You can't add replies to this suggestion, you dont have the proper privileges.");
$this->Redirect($this->Href("","", "&phase=show_sug&id=".$_GET['id']));
** ------------------------------------------------------------------------------- ADD NEW SUGGESTION THREAD
elseif ($phase == 'add_sug')
if ( ( ($this->HasAccess("comment")) && ($this->HasAccess("write")) )|| $this->IsAdmin())
if (!isset($_GET['done']))
$out = $this->Format("@@===New Suggestion===@@");
$out .= "<a href=\"".$this->Href("","", "phase=manage_sugs&sort=all")."\">Suggestions Index</a>";
$out .= $this->Format(">>Minimum **Topic** length is set to ".$min_topic_length." character".(($min_topic_length == 1)? '' : 's')." --- Minimum **Reply** length is set to ".$min_reply_length." character".(($min_reply_length == 1)? '' : 's').">>--- ----");
$out .= "<form action=\"".$this->Href("","", "phase=add_sug&done=1")."\" method=\"post\">\n";
$out .= "\n\tTopic : <br /><textarea id=\"topic_text\" name=\"topic\" cols=\"60\"></textarea><br />";
$out .= "\n\t<label for=\"reply_text\">Add a reply to this suggestion :<br />\n\t\t";
$out .= "\n\t\t<textarea id=\"reply_text\" name=\"body_text\" rows=\"8\" cols=\"60\"></textarea>";
$out .= "\n\t</label><br />";
$out .= "\n\t\t<br /><small>When you are ready to submit your Reply you may press ".$this->Format("#%Alt#%+#%A#%")." or <input value=\"Add New Suggestion\" accesskey=\"a\" type=\"submit\"></small>\n\t";
$out .= $this->FormClose();
echo $this->ReturnSafeHTML($out);
else
if (isset($_GET['done']) )// if the Add Reply was pressed then
{ // check if the lengths of the inputs are ok ...
$_GET['done'] = ( (strlen($_POST['topic']) >= $min_topic_length)&&(strlen($_POST['body_text']) >= $min_reply_length) )? 1 : -1;
}
else // if we reached here from smwh else than the Add Reply Button. .. (possibly a $this->Redirect)
{
$_GET['done'] = 0;
}
switch($_GET['done'])
{
case 1:
$this->Query("INSERT INTO ".$this->config['table_prefix']."suggestions( `title` , `postby` , `time` , `content` , `parent` )
VALUES ( '".addslashes($_POST['topic'])."', '".($this->GetUserName())."', now( ) , '".addslashes($_POST['body_text'])."', 0)");
$_GET['done'] = 0;
$this->SetMessage("New Suggestion Posted");
$this->Redirect($this->Href("","", "phase=manage_sug"));
break;
case -1:
$msg = "The Suggestion Topic has to be more than ".$min_topic_length." character".(($min_topic_length == 1 )?'s' : '')." long and ";
$msg .= "the Suggestion Text has to be more than ".$min_reply_length." character".(($min_reply_length == 1 )?'s' : '')." long.";
$this->SetMessage($msg);
$this->Redirect($this->Href("","", "&phase=add_sug"));
break;
default:
$this->Redirect($this->Href("","", "&phase=add_sug"));
}
** ------------------------------------------------------------------------------- CHANGE STATUS TO A SUGGESTION THREAD
elseif ($phase == 'chng_status')
if ( ($this->IsAdmin()) && ($_GET['t_id'] !== 0) )
$this->Query("UPDATE ".$this->config['table_prefix']."suggestions SET status='".$_GET['sug_status']."' where id=".$_GET['t_id']." or parent=".$_GET['t_id']);
$this->SetMessage("The status of ".GetTitleFromID($_GET['t_id'], $all_sugs)." is now set to ".GetStatusStr($_GET['sug_status']));
$this->Redirect($this->Href("","",( ($_GET['from_phase']=='show_sug') ? "&phase=".$_GET['from_phase']."&id=".$_GET['t_id'] : "phase=".$_GET['from_phase'] ) ));
else // silently redirect to the Suggestions Index ...
$this->Redirect($this-Href("","","phase=manage_sugs"));
?>
%%
===Usage===
You just insert ""{{msgboard}}"" inside any page. Keep in mind that posting on this is affected by the ACLS of the specific page.
===Final Note===
This is my Gift to the Wikka development to enable these wonderfull people behind Wikka to manage the Suggestions they receive ...
Happy New Year to All ;)
----//Suggestions, Modifications as well as comments are most welcome ...//----
Happy New Year to all!
- ++See my comment below for the missing "create entry function"++ I added a little bit to the code above. It should be possible now to add new topics if there are none
- I added a ".$this->config["table_prefix"]." to the first query
- changing the status of a topic does not work with mod_rewrite
- I like this modification very much :) --NilsLindenberg
----
CategoryUserContributions


Revision [15245]

Edited on 2006-08-31 12:13:23 by MartinRenvoize [Reverted]
Additions:
%%(sql)CREATE TABLE `wikka_suggestions` (
Deletions:
%%(sql)CREATE TABLE `suggestions` (


Revision [11646]

Edited on 2005-11-01 07:42:40 by NickDamoulakis [Changed the {{}} keyword shown in the comments at top of code]
Additions:
====Suggestions Message Board====

{{lastedit}}

This action will allow your Wikka installation to have a Message Board.
Before you even try using the script you will need to have the following table inside your wikka mysql database :
%%(sql)CREATE TABLE `suggestions` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`title` VARCHAR( 200 ) NOT NULL ,
`postby` VARCHAR( 100 ) NOT NULL ,
`time` DATETIME NOT NULL ,
`status` ENUM( 'I', 'R', 'P' ) NOT NULL ,
`content` TEXT NOT NULL ,
`parent` INT UNSIGNED DEFAULT '0' NOT NULL ,
PRIMARY KEY ( `id` ) ,
INDEX ( `title` )
) COMMENT = 'suggestions table for the Wikka ...';%%

After this is done you will also need the **/Wikka/actions/msgboard.php** with the following contents:

%%(php)<?php
/*
@filename: msgboard.php
@author: George Petsagourakis
@email: petsagouris@hotmail.com
@date: 2 Jan 2005
@license: GPL

@description: This actions provides a suggestions feature to your Wikka.
It is allowing for replying, deleting, status management and reviewing of posted suggestions.
To use it you will need the following table inside your MySQL database:
CREATE TABLE `suggestions` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`title` VARCHAR( 200 ) NOT NULL ,
`postby` VARCHAR( 100 ) NOT NULL ,
`time` DATETIME NOT NULL ,
`status` ENUM( 'I', 'R', 'P' ) NOT NULL ,
`content` TEXT NOT NULL ,
`parent` INT UNSIGNED DEFAULT '0' NOT NULL ,
PRIMARY KEY ( `id` ) ,
INDEX ( `title` )
) COMMENT = 'suggestions table for the Wikka ...';
@usage: insert {{suggestions}} any where in a wakka page.
NickDamoulakis: Actually, it is meant to be {{msgboard}}
*/


// if there is no phase set then direct to display the "manage subscriptions" table ...
$phase = (isset($_GET['phase'])) ? $_GET['phase'] : 'manage_sugs';

$min_topic_length = 5;
$min_reply_length = 15;

$all_sugs = $this->LoadAll("SELECT * FROM ".$this->config["table_prefix"]."suggestions ORDER BY parent, time");
/*
** ---------------------------------------------------------------------------------------------------------------------------------
** ------------------------------------------------------------------------------- UTILITY FUNCTIONS
** ---------------------------------------------------------------------------------------------------------------------------------
*/
// used for returning an array structure from the MySQL ...
function GetAllSuggestions($arr)
{

$finarr = array();
// lets build the maintable...
foreach($arr as $i => $ar)
{
// handle the parents first...
if ($ar['parent'] == 0)
{
$id = $ar['id'];
$finarr[$ar['id']] = array();
}
else // handle the children...
{
$id = $ar['parent'];

}
foreach($ar as $idx=>$a)
{
$a = stripslashes($a);
}
// put them in the big table ...
$finarr[$id][] = $ar;
}
return $finarr;
}

// used for returning any Status from single letter to whole word .. : 'I' becomes 'Implemented'
function GetStatusStr($str)
{

if ($str == 'I') $str = "Implemented";
elseif ($str == 'R') $str = "Rejected";
elseif ($str == 'P') $str = "Pending";

return $str;
}
// used for adding a dropdown-choose-status field for various parts of the script ...
function AddStatusDropDown($status)
{
$st = array( 'Rejected' => 0, 'Implemented' => 0, 'Pending' => 0);
$st[GetStatusStr($status)] = 1;
$finrow = "\n\t\t\t<select name=\"sug_status\">";
foreach($st as $msg=>$sta)
{
$finrow .= "\n\t\t\t\t<option value=\"".substr($msg, 0,1)."\"".(($sta==1) ? ' selected' : '').">$msg</option>";
}
$finrow .= "\n\t\t\t</select>\n";
//var_dump($finrow);
return $finrow;
}

function GetTitleFromID($id, $arr)
{
foreach (GetAllSuggestions($arr) as $idx => $data)
{
if ($id == $data['id']) return $data['title'];
}
}
// used on sorting the "Manage subscriptions" Table with various configurations...
function SortBy($arr, $func, $val)
{
$res = array();
if ($func == 'author')
{
if ($val && $val!= '')
{
foreach($arr as $i=>$sug)
{
if ($sug['postby'] == $val) $res[] = $sug;
}
return $res;
}
else return $arr;
}
elseif ($func == 'replies')
{
function replies($a, $b)
{
//var_dump($add);
//var_dump($i);
static $add = true;
static $i = 0;

if ($a['replies']){}

$i += ($add) ? 1 : 0 ;
$add = false;
}

}
elseif ($func == 'status')
{
if ($val && $val!= '')
{
foreach($arr as $i=>$sug)
{
if ($sug['status'] == $val) $res[] = $sug;
}
return $res;
}
else return $arr;
}
else
{
return $arr;
}
}
/*
** ---------------------------------------------------------------------------------------------------------------------------------
** ------------------------------------------------------------------------------- DISPLAY ALL SUGGESTION TOPICS
** ---------------------------------------------------------------------------------------------------------------------------------
*/
if ($phase == 'manage_sugs')
{
$sug_arr = GetAllSuggestions($all_sugs);

$sort_get = (isset($_GET['sort'])) ? $_GET['sort'] : 'all';
$name_get = (isset($_GET['name'])) ? $_GET['name'] : 'all';
$status_get = (isset($_GET['status_sort'])) ? $_GET['status_sort'] : 'all';
$sort_get_up = ($_GET['sort_up']) ? ($_GET['sort_up']+0) : (1) ;

$parents = array();

if (!count($sug_arr) == 0)
{
foreach($sug_arr as $id => $data)
{
$cnt = array( 'replies' => (count($data)-1) );
$parents[] = $data[0] + $cnt;
}
$out = $this->Format("==== Suggestions Index ==== //This page contains all the ".( ($_GET['status_sort']!='all') ? GetStatusStr($_GET['status_sort']).' ' : ' ')."suggestions made ".( ($_GET['name'] != 'all' ) ? 'by '.$_GET['name'].' ' : '')."about this Wikka// ----");
// okie .. now we have the array holding the parent-suggestions ... lets make it happen ..
$out .= $this->FormOpen("","","get");
// Add New Suggestion Thread
if ( $this->HasAccess("comment") || $this->HasAccess("write") || $this->IsAdmin() )
{
$out .= "<a href=\"".$this->Href("","", "phase=add_sug")."\">Add Suggestion Thread</a>";
}

// Status Sorting ...
$out .= " | Show only ";
$st = array( 'Rejected' => 0, 'Implemented' => 0, 'Pending' => 0);
if ($status_get != 'all') { $st[GetStatusStr($status_get)] = 1;}

$out .= "\n\t\t\t<select name=\"status_sort\">";
$out .= "<option value=\"all\"".( ($status_get == 'all')?" selected":"").">Any</option>";
foreach($st as $msg=>$sta)
{
$out .= "\n\t\t\t\t<option value=\"".substr($msg, 0,1)."\"".(($sta==1) ? ' selected' : '').">$msg</option>";
}
$out .= "\n\t\t\t</select>";

// Search By Author
$out .= " suggested by ";
$out .= "";
$st = array();
$tot = 0;
foreach($this->LoadAll("SELECT id,postby FROM ".$this->config['table_prefix']."suggestions WHERE parent = '0'") as $idx => $data)
{
if ( ($st[$data['postby']]) || ($st[$data['postby']] > 1) )
$st[$data['postby']] += 1;
else
$st[$data['postby']] = 1;

$tot++;
}

$out .= "\n\t\t\t<select name=\"name\">";
$out .= "\n\t\t\t\t<option value=\"all\"".(($name_get=='all')?" selected":"").">Anyone ($tot)</option>";
foreach($st as $author => $count)
{
if (strlen($author) > 0)
$out .= "\n\t\t\t\t<option value=\"".$author."\"".(($name_get==$author)?" selected":"").">".$author." (".$count.")</option>";
}
$out .= "\n\t\t\t</select>";
$out .= "\n\t\t\t<input value=\" Go \" accesskey=\"g\" type=\"submit\"/>";
$out .= "\n\t\t".$this->FormClose()."\n\t\t<hr />";

// Created the topmost links bar ...
if ($sort_get != 'all')
{
// sort out the 'title' 'time' or 'postby'
if ( ($sort_get == 'title') || ($sort_get == 'time') || ($sort_get == 'status')) // TO FIX !!! //
{
$res = $this->LoadAll("SELECT * FROM ".$this->config['table_prefix']."suggestions WHERE parent = '0' ORDER BY ".$sort_get);
$parents = array();

foreach($res as $idx => $data)
{
if ($data['parent'] == 0)
{
$id = $data['id'];
$parents[$data['id']] = array();
}
else // handle the children...
{
$id = $data['parent'];
}
foreach($data as $i => $a)
{
$a = stripslashes($a);
}
$parents[$id][] = $data;
}

foreach($sug_arr as $idx => $info)
{
$cnt = array( 'replies' => (count($info)-1) );
foreach($parents as $i => $a)
{
if ($a[0]['id'] == $idx) $parents[$i] = array_merge($a[0] ,$cnt);
}
}

$parents = ($sort_get_up==1)? array_reverse($parents) :$parents ;

}
elseif ($sort_get == 'replies')
{
function repliesSB($a, $b)
{
if ($a["replies"]== $b["replies"]) return 0;
return ($a["replies"] > $b["replies"]) ? 1 : -1 ;
}
function repliesBS($a, $b)
{
if ($a["replies"]== $b["replies"]) return 0;
return ($a["replies"] < $b["replies"]) ? 1 : -1 ;
}
uasort($parents, "replies".(($sort_get_up==1)?"BS":"SB")) ;
}
elseif ($sort_get == 'postby')
{
function postbyBS($a, $b)
{
if ($a['postby'] == $b['postby']) return 0;
return ($a['postby'] < $b['postby']) ? -1 : 1;
}
function postbySB($a, $b)
{
if ($a['postby'] == $b['postby']) return 0;
return ($a['postby'] < $b['postby']) ? 1 : -1;
}
uasort($parents, 'postby'.(($sort_get_up==-1)?'BS':'SB'));
}

}
// The author filtering ...
if ($name_get !='all') {
$res = $parents;
$parents = array();
foreach($res as $i=>$info)
{
if ($info['postby'] === $name_get)
$parents[$i] = $info;
}
}
// The status filtering ...
if ($status_get !='all') {
$res = $parents;
$parents = array();
foreach($res as $i=>$info)
{
if ($info['status'] === $status_get)
$parents[$i] = $info;
}
}

// ------------- CREATING THE DISPLAY TABLE FROM $parents ARRAY...

$out .= "\n\t<table align=\"center\" width=\"90%\">";
$out .= "\n\t<tbody align=\"center\" bgcolor=\"#999999\">";
$out .= "\n\t\t<th>".((($_GET['sort_up']==1||$_GET['sort_up']==-1) && ($sort_get =='title') )? (($sort_get_up==-1)? "⇓" : "⇑"):'')."<a href=\"".$this->Href("","", "phase=manage_sugs&sort=title&sort_up=".(-$sort_get_up))."\">Topic</a></th>";
$out .= "\n\t\t<th>".((($_GET['sort_up']==1||$_GET['sort_up']==-1) && ($sort_get =='status') )? (($sort_get_up==-1)? "⇓" : "⇑"):'')."<a href=\"".$this->Href("","", "phase=manage_sugs&sort=status&sort_up=".(-$sort_get_up))."\">Status</a></th>";
$out .= "\n\t\t<th>".((($_GET['sort_up']==1||$_GET['sort_up']==-1) && ($sort_get =='postby') )? (($sort_get_up==-1)? "⇓" : "⇑"):'')."<a href=\"".$this->Href("","", "phase=manage_sugs&sort=postby&sort_up=".(-$sort_get_up))."\">Author</a></th>";
$out .= "\n\t\t<th>".((($_GET['sort_up']==1||$_GET['sort_up']==-1) && ($sort_get =='time') )? (($sort_get_up==-1)? "⇓" : "⇑"):'')."<a href=\"".$this->Href("","", "phase=manage_sugs&sort=time&sort_up=".(-$sort_get_up))."\">Posted On</a></th>";
$out .= "\n\t\t<th>".((($_GET['sort_up']==1||$_GET['sort_up']==-1) && ($sort_get =='replies') )? (($sort_get_up==-1)? "⇓" : "⇑"):'')."<a href=\"".$this->Href("","", "phase=manage_sugs&sort=replies&sort_up=".(-$sort_get_up))."\">Replies</a></th>";
if ($this->IsAdmin($this->GetUser()))
{
$out .= "\n\t\t<th>Actions</th>";
}
$out .= "\n\t</tbody>\n\t";
if (count($parents) > 0)
{
foreach($parents as $i=>$data)
{
$out .= "\t<tr>";
$out .= "\n\t\t<td><a href=\"".$this->Href("","", "phase=show_sug&id=".$data['id'])."\">".$data['title']."</a></td>";
$out .= "\n\t\t<td>".GetStatusStr($data['status'])."</td>";
$out .= "\n\t\t<td>".$this->Format($data['postby'])."</td>";
$out .= "\n\t\t<td>".$data['time']."</td>";
$out .= "\n\t\t<td align=\"center\">".$data['replies']."</td>";
if ($this->IsAdmin($this->GetUser()))
{
$st = array( 'Rejected' => 0, 'Implemented' => 0, 'Pending' => 0);
$st[GetStatusStr($data['status'])] = 1;
$out .= "\n\t\t<td>";
$out .= "\n\t\t<form action=\"".$this->config["base_url"].$this->PageTitle().( ($this->config["rewrite_mode"]) ? "?" : "&")."\" method=\"get\">\n";
$out .= "\n\t\t\t<a href=\"".$this->Href("","","phase=del_sug&delid=".$data['id'])."\">Delete</a> |";

$out .= "\n\t\t\t<input type=\"hidden\" name=\"wakka\" value=\"".$this->PageTitle()."\"/>";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"phase\" value=\"chng_status\"/>";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"t_id\" value=\"".$data['id']."\"/>";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"from_phase\" value=\"".$phase."\"/>";
$out .= "\n\t\t\tChange to <select name=\"sug_status\">";
foreach($st as $msg=>$sta)
{
$out .= "\n\t\t\t\t<option value=\"".substr($msg, 0,1)."\"".(($sta==1) ? ' selected' : '').">$msg</option>";
}
$out .= "\n\t\t\t</select>\n";
$out .= "\n\t\t\t<input type=\"submit\" value=\" Go \"/>";
$out .= "\n\t\t</form>";
}
$out .= "\n\t\t</tr>";
}
}
else
{
$out .= "</table>\n\t".$this->Format("--- @@//===No Matches===//@@ --- ");
}

}
else
{
$out = "<table><tr><td>No Suggestions yet ...</td>";
if ( $this->HasAccess("comment") || $this->HasAccess("write") || $this->IsAdmin() )
{
$out .="<tr><tr><td><a href=\"".$this->Href("","", "phase=add_sug")."\">Add Suggestion Thread</a>";
}
$out .="</td></tr></table>";
}

echo $this->ReturnSafeHTML($out);
}
/*
** ---------------------------------------------------------------------------------------------------------------------------------
** ------------------------------------------------------------------------------- DISPLAY A SUGGESTION THREAD
** ---------------------------------------------------------------------------------------------------------------------------------
*/
elseif ($phase == 'show_sug')
{
$id = $_GET['id']+0;
$sug_arr = GetAllSuggestions($all_sugs);
$sug_arr = $sug_arr[$id];

$st = array( 'Rejected' => 0, 'Implemented' => 0, 'Pending' => 0);
$st[GetStatusStr($sug_arr[0]['status'])] = 1;

$out = $this->Format("====".$sug_arr[0]['title']."==== //The proposed suggestion is ".GetStatusStr($sug_arr[0]['status'])."//");
$out .= "\n\t\t<form action=\"".$this->config["base_url"].$this->PageTitle().( ($this->config["rewrite_mode"]) ? "?" : "&")."\" method=\"get\">\n";
$out .= "<a href=\"".$this->Href("","", "phase=manage_sugs&sort=all\"").">Suggestions Index</a> | ";
$out .= "<a href=\"".$this->Href("","", "&phase=add_sug\"").">New Suggestion</a> | ";
$out .= "\n\t\t\t<a href=\"".$this->Href("","","phase=del_sug&delid=".$id)."\">Delete This Suggestion Thread</a> |";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"wakka\" value=\"".$this->PageTitle()."\"/>";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"phase\" value=\"chng_status\"/>";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"t_id\" value=\"".$sug_arr[0]['id']."\"/>";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"from_phase\" value=\"".$phase."\"/>";
$out .= "\n\t\t\tChange Status to <select name=\"sug_status\">";
foreach($st as $msg=>$sta)
{
$out .= "\n\t\t\t\t<option value=\"".substr($msg, 0,1)."\"".(($sta==1) ? ' selected' : '').">$msg</option>";
}
$out .= "\n\t\t\t</select>\n";
$out .= "\n\t\t\t<input type=\"submit\" value=\" Go \"/>";
$out .= "\n\t\t</form>";

$out.= $this->Format("----");

foreach($sug_arr as $i => $data)
{
$out .= "\n<table width=\"100%\">";
$out .= "\n\t<tr>\n\t\t<td colspan=\"2\">".($this->Format("**".$data['title']."**"));
// if this is the owner and this isnt a first suggestion , or this is an admin .. then add a delete button ...
if (!$data['parent']==0)
{
if ( ($this->GetUserName() == $data['postby']) || ($this->IsAdmin($this->GetUser())) )
{
$out .= " | <small><a href=\"".$this->Href("","", "&phase=del_sug&id=".$id."&delid=".$data['id'])."&title=".htmlspecialchars($data['title'])."\">Delete</a></small>";
}
}
$out .= "\n\t\t</td>\n\t</tr>";
$out .= "\n\t<tr>\n\t\t<td bgcolor=\"#999999\" width=\"5%\"></td>\n\t\t<td>".($this->Format($data['content']))."</td>\n\t</tr>";
// do the final row on this particular suggestion entry ...
$out .= "\n\t<tr>\n\t\t<td colspan=\"2\"><small>".($this->Format("//".$data['postby']." posted on ".$data['time']."//"))."</small></td>\n\t</tr>";
$out .= "\n</table>\n<hr />";
}
if ( ( ($this->HasAccess("comment")) && ($this->HasAccess("write")) )|| $this->IsAdmin())
{
$out .= "<form action=\"".$this->Href("","", "phase=reply_to&id=".$id)."\" method=\"post\">\n";
$out .= "<input type=\"hidden\" name=\"status\" value=\"".$data['status']."\">";
$out .= "\n\tTopic : <br /><textarea id=\"topic_text\" name=\"topic\" cols=\"78\"></textarea><br />";

$out .= "\n\t<label for=\"reply_text\">Add a reply to this suggestion :<br />\n\t\t";
$out .= "\n\t\t<textarea id=\"reply_text\" name=\"body\" rows=\"6\" cols=\"78\"></textarea>";
$out .= "\n\t</label><br />";

$out .= "\n\t\t<br /><small>When you are ready to submit your Reply you may press ".$this->Format("#%Alt#%+#%A#%")." or <input value=\"Add Reply\" accesskey=\"a\" type=\"submit\"/>\n\t";
$out .= $this->FormClose();
}
echo $this->ReturnSafeHTML($out);
}
/*
** ---------------------------------------------------------------------------------------------------------------------------------
** ------------------------------------------------------------------------------- DELETE REPLY
** ---------------------------------------------------------------------------------------------------------------------------------
*/
elseif ($phase == 'del_sug')
{
if ( isset($_GET['delid']) && ($_GET['delid'] != "") )
{
if ( ($this->GetUserName() == $data['postby']) || ($this->IsAdmin($this->GetUser())) )
{
$delid = $_GET['delid'];
$parent_id = $_GET['id'];
if ( ($delid == $parent_id) && ($this->IsAdmin($this->GetUser())) )
{
$msg = "The thread entitled : ".$_GET['title']." was deleted";
$url = "&phase=show_sug&id=".$parent_id;
}
else
{
$msg = "The reply to the ".( (isset($_GET['title'])) ? $_GET['title'] : 'suggestion')." was deleted.";
$url = "phase=manage_sugs";
}
$this->Query("DELETE FROM ".$this->config["table_prefix"]."suggestions WHERE (id = '".$delid."' or parent='".$delid."')");
$this->SetMessage($msg);
$this->Redirect($this->Href("","", $url));
}
}
else
{
$this->Redirect($this->Href("","", "&phase=show_sug&id=".$_GET['id']));
}
}
/*
** ---------------------------------------------------------------------------------------------------------------------------------
** ------------------------------------------------------------------------------- REPLY TO SUGGESTION
** ---------------------------------------------------------------------------------------------------------------------------------
*/
elseif ($phase == 'reply_to')
{
if ( ( ($this->HasAccess("comment")) && ($this->HasAccess("write")) )|| $this->IsAdmin())
{
if (($_POST['status'] != "I") && ($_POST['status'] != "R"))
{
$this->Query("INSERT INTO ".$this->config["table_prefix"]."suggestions (title,postby,time,status,content,parent) ".
"VALUES ('".addslashes($_POST['topic'])."', '".($this->GetUserName())."', NOW(), '".$_POST['status']."', '".addslashes($_POST['body'])."', '".$_GET['id']."')");
$this->SetMessage("The reply to the \"".( (isset($_GET['title'])) ? $_GET['title'] : 'suggestion')."\" was added." );
$this->Redirect($this->Href("","", "&phase=show_sug&id=".$_GET['id']));
}
else
{
$this->SetMessage("You can't add replies to this suggestion. Its status is set to ".GetStatusStr($sug_arr['status']));
$this->Redirect($this->Href("","", "&phase=show_sug&id=".$_GET['id']));
}
}
else
{
$this->SetMessage("You can't add replies to this suggestion, you dont have the proper privileges.");
$this->Redirect($this->Href("","", "&phase=show_sug&id=".$_GET['id']));
}
}
/*
** ---------------------------------------------------------------------------------------------------------------------------------
** ------------------------------------------------------------------------------- ADD NEW SUGGESTION THREAD
** ---------------------------------------------------------------------------------------------------------------------------------
*/
elseif ($phase == 'add_sug')
{
if ( ( ($this->HasAccess("comment")) && ($this->HasAccess("write")) )|| $this->IsAdmin())
{
if (!isset($_GET['done']))
{
$out = $this->Format("@@===New Suggestion===@@");
$out .= "<a href=\"".$this->Href("","", "phase=manage_sugs&sort=all")."\">Suggestions Index</a>";
$out .= $this->Format(">>Minimum **Topic** length is set to ".$min_topic_length." character".(($min_topic_length == 1)? '' : 's')." --- Minimum **Reply** length is set to ".$min_reply_length." character".(($min_reply_length == 1)? '' : 's').">>--- ----");
$out .= "<form action=\"".$this->Href("","", "phase=add_sug&done=1")."\" method=\"post\">\n";
$out .= "\n\tTopic : <br /><textarea id=\"topic_text\" name=\"topic\" cols=\"60\"></textarea><br />";
$out .= "\n\t<label for=\"reply_text\">Add a reply to this suggestion :<br />\n\t\t";
$out .= "\n\t\t<textarea id=\"reply_text\" name=\"body_text\" rows=\"8\" cols=\"60\"></textarea>";
$out .= "\n\t</label><br />";

$out .= "\n\t\t<br /><small>When you are ready to submit your Reply you may press ".$this->Format("#%Alt#%+#%A#%")." or <input value=\"Add New Suggestion\" accesskey=\"a\" type=\"submit\"></small>\n\t";
$out .= $this->FormClose();
echo $this->ReturnSafeHTML($out);
}
else
{
if (isset($_GET['done']) )// if the Add Reply was pressed then
{ // check if the lengths of the inputs are ok ...
$_GET['done'] = ( (strlen($_POST['topic']) >= $min_topic_length)&&(strlen($_POST['body_text']) >= $min_reply_length) )? 1 : -1;
}
else // if we reached here from smwh else than the Add Reply Button. .. (possibly a $this->Redirect)
{
$_GET['done'] = 0;
}
switch($_GET['done'])
{
case 1:
$this->Query("INSERT INTO ".$this->config['table_prefix']."suggestions( `title` , `postby` , `time` , `content` , `parent` )
VALUES ( '".addslashes($_POST['topic'])."', '".($this->GetUserName())."', now( ) , '".addslashes($_POST['body_text'])."', 0)");
$_GET['done'] = 0;
$this->SetMessage("New Suggestion Posted");
$this->Redirect($this->Href("","", "phase=manage_sug"));
break;
case -1:
$msg = "The Suggestion Topic has to be more than ".$min_topic_length." character".(($min_topic_length == 1 )?'s' : '')." long and ";
$msg .= "the Suggestion Text has to be more than ".$min_reply_length." character".(($min_reply_length == 1 )?'s' : '')." long.";
$this->SetMessage($msg);
$this->Redirect($this->Href("","", "&phase=add_sug"));
break;
default:
$this->Redirect($this->Href("","", "&phase=add_sug"));
}
}
}
}
/*
** ---------------------------------------------------------------------------------------------------------------------------------
** ------------------------------------------------------------------------------- CHANGE STATUS TO A SUGGESTION THREAD
** ---------------------------------------------------------------------------------------------------------------------------------
*/
elseif ($phase == 'chng_status')
{
if ( ($this->IsAdmin()) && ($_GET['t_id'] !== 0) )
{
$this->Query("UPDATE ".$this->config['table_prefix']."suggestions SET status='".$_GET['sug_status']."' where id=".$_GET['t_id']." or parent=".$_GET['t_id']);
$this->SetMessage("The status of ".GetTitleFromID($_GET['t_id'], $all_sugs)." is now set to ".GetStatusStr($_GET['sug_status']));
$this->Redirect($this->Href("","",( ($_GET['from_phase']=='show_sug') ? "&phase=".$_GET['from_phase']."&id=".$_GET['t_id'] : "phase=".$_GET['from_phase'] ) ));
}
else // silently redirect to the Suggestions Index ...
{
$this->Redirect($this-Href("","","phase=manage_sugs"));
}
}
?>
%%

===Usage===
You just insert ""{{msgboard}}"" inside any page. Keep in mind that posting on this is affected by the ACLS of the specific page.

===Final Note===
This is my Gift to the Wikka development to enable these wonderfull people behind Wikka to manage the Suggestions they receive ...
Happy New Year to All ;)
----//Suggestions, Modifications as well as comments are most welcome ...//----

Happy New Year to all!
- ++See my comment below for the missing "create entry function"++ I added a little bit to the code above. It should be possible now to add new topics if there are none
- I added a ".$this->config["table_prefix"]." to the first query
- changing the status of a topic does not work with mod_rewrite
- I like this modification very much :) --NilsLindenberg

----
Deletions:
====Suggestions Message Board====

{{lastedit}}

This action will allow your Wikka installation to have a Message Board.
Before you even try using the script you will need to have the following table inside your wikka mysql database :
%%(sql)CREATE TABLE `suggestions` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`title` VARCHAR( 200 ) NOT NULL ,
`postby` VARCHAR( 100 ) NOT NULL ,
`time` DATETIME NOT NULL ,
`status` ENUM( 'I', 'R', 'P' ) NOT NULL ,
`content` TEXT NOT NULL ,
`parent` INT UNSIGNED DEFAULT '0' NOT NULL ,
PRIMARY KEY ( `id` ) ,
INDEX ( `title` )
) COMMENT = 'suggestions table for the Wikka ...';%%

After this is done you will also need the **/Wikka/actions/msgboard.php** with the following contents:

%%(php)<?php
/*
@filename: msgboard.php
@author: George Petsagourakis
@email: petsagouris@hotmail.com
@date: 2 Jan 2005
@license: GPL

@description: This actions provides a suggestions feature to your Wikka.
It is allowing for replying, deleting, status management and reviewing of posted suggestions.
To use it you will need the following table inside your MySQL database:
CREATE TABLE `suggestions` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`title` VARCHAR( 200 ) NOT NULL ,
`postby` VARCHAR( 100 ) NOT NULL ,
`time` DATETIME NOT NULL ,
`status` ENUM( 'I', 'R', 'P' ) NOT NULL ,
`content` TEXT NOT NULL ,
`parent` INT UNSIGNED DEFAULT '0' NOT NULL ,
PRIMARY KEY ( `id` ) ,
INDEX ( `title` )
) COMMENT = 'suggestions table for the Wikka ...';
@usage: insert {{suggestions}} any where in a wakka page.
*/


// if there is no phase set then direct to display the "manage subscriptions" table ...
$phase = (isset($_GET['phase'])) ? $_GET['phase'] : 'manage_sugs';

$min_topic_length = 5;
$min_reply_length = 15;

$all_sugs = $this->LoadAll("SELECT * FROM ".$this->config["table_prefix"]."suggestions ORDER BY parent, time");
/*
** ---------------------------------------------------------------------------------------------------------------------------------
** ------------------------------------------------------------------------------- UTILITY FUNCTIONS
** ---------------------------------------------------------------------------------------------------------------------------------
*/
// used for returning an array structure from the MySQL ...
function GetAllSuggestions($arr)
{

$finarr = array();
// lets build the maintable...
foreach($arr as $i => $ar)
{
// handle the parents first...
if ($ar['parent'] == 0)
{
$id = $ar['id'];
$finarr[$ar['id']] = array();
}
else // handle the children...
{
$id = $ar['parent'];

}
foreach($ar as $idx=>$a)
{
$a = stripslashes($a);
}
// put them in the big table ...
$finarr[$id][] = $ar;
}
return $finarr;
}

// used for returning any Status from single letter to whole word .. : 'I' becomes 'Implemented'
function GetStatusStr($str)
{

if ($str == 'I') $str = "Implemented";
elseif ($str == 'R') $str = "Rejected";
elseif ($str == 'P') $str = "Pending";

return $str;
}
// used for adding a dropdown-choose-status field for various parts of the script ...
function AddStatusDropDown($status)
{
$st = array( 'Rejected' => 0, 'Implemented' => 0, 'Pending' => 0);
$st[GetStatusStr($status)] = 1;
$finrow = "\n\t\t\t<select name=\"sug_status\">";
foreach($st as $msg=>$sta)
{
$finrow .= "\n\t\t\t\t<option value=\"".substr($msg, 0,1)."\"".(($sta==1) ? ' selected' : '').">$msg</option>";
}
$finrow .= "\n\t\t\t</select>\n";
//var_dump($finrow);
return $finrow;
}

function GetTitleFromID($id, $arr)
{
foreach (GetAllSuggestions($arr) as $idx => $data)
{
if ($id == $data['id']) return $data['title'];
}
}
// used on sorting the "Manage subscriptions" Table with various configurations...
function SortBy($arr, $func, $val)
{
$res = array();
if ($func == 'author')
{
if ($val && $val!= '')
{
foreach($arr as $i=>$sug)
{
if ($sug['postby'] == $val) $res[] = $sug;
}
return $res;
}
else return $arr;
}
elseif ($func == 'replies')
{
function replies($a, $b)
{
//var_dump($add);
//var_dump($i);
static $add = true;
static $i = 0;

if ($a['replies']){}

$i += ($add) ? 1 : 0 ;
$add = false;
}

}
elseif ($func == 'status')
{
if ($val && $val!= '')
{
foreach($arr as $i=>$sug)
{
if ($sug['status'] == $val) $res[] = $sug;
}
return $res;
}
else return $arr;
}
else
{
return $arr;
}
}
/*
** ---------------------------------------------------------------------------------------------------------------------------------
** ------------------------------------------------------------------------------- DISPLAY ALL SUGGESTION TOPICS
** ---------------------------------------------------------------------------------------------------------------------------------
*/
if ($phase == 'manage_sugs')
{
$sug_arr = GetAllSuggestions($all_sugs);

$sort_get = (isset($_GET['sort'])) ? $_GET['sort'] : 'all';
$name_get = (isset($_GET['name'])) ? $_GET['name'] : 'all';
$status_get = (isset($_GET['status_sort'])) ? $_GET['status_sort'] : 'all';
$sort_get_up = ($_GET['sort_up']) ? ($_GET['sort_up']+0) : (1) ;

$parents = array();

if (!count($sug_arr) == 0)
{
foreach($sug_arr as $id => $data)
{
$cnt = array( 'replies' => (count($data)-1) );
$parents[] = $data[0] + $cnt;
}
$out = $this->Format("==== Suggestions Index ==== //This page contains all the ".( ($_GET['status_sort']!='all') ? GetStatusStr($_GET['status_sort']).' ' : ' ')."suggestions made ".( ($_GET['name'] != 'all' ) ? 'by '.$_GET['name'].' ' : '')."about this Wikka// ----");
// okie .. now we have the array holding the parent-suggestions ... lets make it happen ..
$out .= $this->FormOpen("","","get");
// Add New Suggestion Thread
if ( $this->HasAccess("comment") || $this->HasAccess("write") || $this->IsAdmin() )
{
$out .= "<a href=\"".$this->Href("","", "phase=add_sug")."\">Add Suggestion Thread</a>";
}

// Status Sorting ...
$out .= " | Show only ";
$st = array( 'Rejected' => 0, 'Implemented' => 0, 'Pending' => 0);
if ($status_get != 'all') { $st[GetStatusStr($status_get)] = 1;}

$out .= "\n\t\t\t<select name=\"status_sort\">";
$out .= "<option value=\"all\"".( ($status_get == 'all')?" selected":"").">Any</option>";
foreach($st as $msg=>$sta)
{
$out .= "\n\t\t\t\t<option value=\"".substr($msg, 0,1)."\"".(($sta==1) ? ' selected' : '').">$msg</option>";
}
$out .= "\n\t\t\t</select>";

// Search By Author
$out .= " suggested by ";
$out .= "";
$st = array();
$tot = 0;
foreach($this->LoadAll("SELECT id,postby FROM ".$this->config['table_prefix']."suggestions WHERE parent = '0'") as $idx => $data)
{
if ( ($st[$data['postby']]) || ($st[$data['postby']] > 1) )
$st[$data['postby']] += 1;
else
$st[$data['postby']] = 1;

$tot++;
}

$out .= "\n\t\t\t<select name=\"name\">";
$out .= "\n\t\t\t\t<option value=\"all\"".(($name_get=='all')?" selected":"").">Anyone ($tot)</option>";
foreach($st as $author => $count)
{
if (strlen($author) > 0)
$out .= "\n\t\t\t\t<option value=\"".$author."\"".(($name_get==$author)?" selected":"").">".$author." (".$count.")</option>";
}
$out .= "\n\t\t\t</select>";
$out .= "\n\t\t\t<input value=\" Go \" accesskey=\"g\" type=\"submit\"/>";
$out .= "\n\t\t".$this->FormClose()."\n\t\t<hr />";

// Created the topmost links bar ...
if ($sort_get != 'all')
{
// sort out the 'title' 'time' or 'postby'
if ( ($sort_get == 'title') || ($sort_get == 'time') || ($sort_get == 'status')) // TO FIX !!! //
{
$res = $this->LoadAll("SELECT * FROM ".$this->config['table_prefix']."suggestions WHERE parent = '0' ORDER BY ".$sort_get);
$parents = array();

foreach($res as $idx => $data)
{
if ($data['parent'] == 0)
{
$id = $data['id'];
$parents[$data['id']] = array();
}
else // handle the children...
{
$id = $data['parent'];
}
foreach($data as $i => $a)
{
$a = stripslashes($a);
}
$parents[$id][] = $data;
}

foreach($sug_arr as $idx => $info)
{
$cnt = array( 'replies' => (count($info)-1) );
foreach($parents as $i => $a)
{
if ($a[0]['id'] == $idx) $parents[$i] = array_merge($a[0] ,$cnt);
}
}

$parents = ($sort_get_up==1)? array_reverse($parents) :$parents ;

}
elseif ($sort_get == 'replies')
{
function repliesSB($a, $b)
{
if ($a["replies"]== $b["replies"]) return 0;
return ($a["replies"] > $b["replies"]) ? 1 : -1 ;
}
function repliesBS($a, $b)
{
if ($a["replies"]== $b["replies"]) return 0;
return ($a["replies"] < $b["replies"]) ? 1 : -1 ;
}
uasort($parents, "replies".(($sort_get_up==1)?"BS":"SB")) ;
}
elseif ($sort_get == 'postby')
{
function postbyBS($a, $b)
{
if ($a['postby'] == $b['postby']) return 0;
return ($a['postby'] < $b['postby']) ? -1 : 1;
}
function postbySB($a, $b)
{
if ($a['postby'] == $b['postby']) return 0;
return ($a['postby'] < $b['postby']) ? 1 : -1;
}
uasort($parents, 'postby'.(($sort_get_up==-1)?'BS':'SB'));
}

}
// The author filtering ...
if ($name_get !='all') {
$res = $parents;
$parents = array();
foreach($res as $i=>$info)
{
if ($info['postby'] === $name_get)
$parents[$i] = $info;
}
}
// The status filtering ...
if ($status_get !='all') {
$res = $parents;
$parents = array();
foreach($res as $i=>$info)
{
if ($info['status'] === $status_get)
$parents[$i] = $info;
}
}

// ------------- CREATING THE DISPLAY TABLE FROM $parents ARRAY...

$out .= "\n\t<table align=\"center\" width=\"90%\">";
$out .= "\n\t<tbody align=\"center\" bgcolor=\"#999999\">";
$out .= "\n\t\t<th>".((($_GET['sort_up']==1||$_GET['sort_up']==-1) && ($sort_get =='title') )? (($sort_get_up==-1)? "⇓" : "⇑"):'')."<a href=\"".$this->Href("","", "phase=manage_sugs&sort=title&sort_up=".(-$sort_get_up))."\">Topic</a></th>";
$out .= "\n\t\t<th>".((($_GET['sort_up']==1||$_GET['sort_up']==-1) && ($sort_get =='status') )? (($sort_get_up==-1)? "⇓" : "⇑"):'')."<a href=\"".$this->Href("","", "phase=manage_sugs&sort=status&sort_up=".(-$sort_get_up))."\">Status</a></th>";
$out .= "\n\t\t<th>".((($_GET['sort_up']==1||$_GET['sort_up']==-1) && ($sort_get =='postby') )? (($sort_get_up==-1)? "⇓" : "⇑"):'')."<a href=\"".$this->Href("","", "phase=manage_sugs&sort=postby&sort_up=".(-$sort_get_up))."\">Author</a></th>";
$out .= "\n\t\t<th>".((($_GET['sort_up']==1||$_GET['sort_up']==-1) && ($sort_get =='time') )? (($sort_get_up==-1)? "⇓" : "⇑"):'')."<a href=\"".$this->Href("","", "phase=manage_sugs&sort=time&sort_up=".(-$sort_get_up))."\">Posted On</a></th>";
$out .= "\n\t\t<th>".((($_GET['sort_up']==1||$_GET['sort_up']==-1) && ($sort_get =='replies') )? (($sort_get_up==-1)? "⇓" : "⇑"):'')."<a href=\"".$this->Href("","", "phase=manage_sugs&sort=replies&sort_up=".(-$sort_get_up))."\">Replies</a></th>";
if ($this->IsAdmin($this->GetUser()))
{
$out .= "\n\t\t<th>Actions</th>";
}
$out .= "\n\t</tbody>\n\t";
if (count($parents) > 0)
{
foreach($parents as $i=>$data)
{
$out .= "\t<tr>";
$out .= "\n\t\t<td><a href=\"".$this->Href("","", "phase=show_sug&id=".$data['id'])."\">".$data['title']."</a></td>";
$out .= "\n\t\t<td>".GetStatusStr($data['status'])."</td>";
$out .= "\n\t\t<td>".$this->Format($data['postby'])."</td>";
$out .= "\n\t\t<td>".$data['time']."</td>";
$out .= "\n\t\t<td align=\"center\">".$data['replies']."</td>";
if ($this->IsAdmin($this->GetUser()))
{
$st = array( 'Rejected' => 0, 'Implemented' => 0, 'Pending' => 0);
$st[GetStatusStr($data['status'])] = 1;
$out .= "\n\t\t<td>";
$out .= "\n\t\t<form action=\"".$this->config["base_url"].$this->PageTitle().( ($this->config["rewrite_mode"]) ? "?" : "&")."\" method=\"get\">\n";
$out .= "\n\t\t\t<a href=\"".$this->Href("","","phase=del_sug&delid=".$data['id'])."\">Delete</a> |";

$out .= "\n\t\t\t<input type=\"hidden\" name=\"wakka\" value=\"".$this->PageTitle()."\"/>";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"phase\" value=\"chng_status\"/>";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"t_id\" value=\"".$data['id']."\"/>";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"from_phase\" value=\"".$phase."\"/>";
$out .= "\n\t\t\tChange to <select name=\"sug_status\">";
foreach($st as $msg=>$sta)
{
$out .= "\n\t\t\t\t<option value=\"".substr($msg, 0,1)."\"".(($sta==1) ? ' selected' : '').">$msg</option>";
}
$out .= "\n\t\t\t</select>\n";
$out .= "\n\t\t\t<input type=\"submit\" value=\" Go \"/>";
$out .= "\n\t\t</form>";
}
$out .= "\n\t\t</tr>";
}
}
else
{
$out .= "</table>\n\t".$this->Format("--- @@//===No Matches===//@@ --- ");
}

}
else
{
$out = "<table><tr><td>No Suggestions yet ...</td>";
if ( $this->HasAccess("comment") || $this->HasAccess("write") || $this->IsAdmin() )
{
$out .="<tr><tr><td><a href=\"".$this->Href("","", "phase=add_sug")."\">Add Suggestion Thread</a>";
}
$out .="</td></tr></table>";
}

echo $this->ReturnSafeHTML($out);
}
/*
** ---------------------------------------------------------------------------------------------------------------------------------
** ------------------------------------------------------------------------------- DISPLAY A SUGGESTION THREAD
** ---------------------------------------------------------------------------------------------------------------------------------
*/
elseif ($phase == 'show_sug')
{
$id = $_GET['id']+0;
$sug_arr = GetAllSuggestions($all_sugs);
$sug_arr = $sug_arr[$id];

$st = array( 'Rejected' => 0, 'Implemented' => 0, 'Pending' => 0);
$st[GetStatusStr($sug_arr[0]['status'])] = 1;

$out = $this->Format("====".$sug_arr[0]['title']."==== //The proposed suggestion is ".GetStatusStr($sug_arr[0]['status'])."//");
$out .= "\n\t\t<form action=\"".$this->config["base_url"].$this->PageTitle().( ($this->config["rewrite_mode"]) ? "?" : "&")."\" method=\"get\">\n";
$out .= "<a href=\"".$this->Href("","", "phase=manage_sugs&sort=all\"").">Suggestions Index</a> | ";
$out .= "<a href=\"".$this->Href("","", "&phase=add_sug\"").">New Suggestion</a> | ";
$out .= "\n\t\t\t<a href=\"".$this->Href("","","phase=del_sug&delid=".$id)."\">Delete This Suggestion Thread</a> |";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"wakka\" value=\"".$this->PageTitle()."\"/>";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"phase\" value=\"chng_status\"/>";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"t_id\" value=\"".$sug_arr[0]['id']."\"/>";
$out .= "\n\t\t\t<input type=\"hidden\" name=\"from_phase\" value=\"".$phase."\"/>";
$out .= "\n\t\t\tChange Status to <select name=\"sug_status\">";
foreach($st as $msg=>$sta)
{
$out .= "\n\t\t\t\t<option value=\"".substr($msg, 0,1)."\"".(($sta==1) ? ' selected' : '').">$msg</option>";
}
$out .= "\n\t\t\t</select>\n";
$out .= "\n\t\t\t<input type=\"submit\" value=\" Go \"/>";
$out .= "\n\t\t</form>";

$out.= $this->Format("----");

foreach($sug_arr as $i => $data)
{
$out .= "\n<table width=\"100%\">";
$out .= "\n\t<tr>\n\t\t<td colspan=\"2\">".($this->Format("**".$data['title']."**"));
// if this is the owner and this isnt a first suggestion , or this is an admin .. then add a delete button ...
if (!$data['parent']==0)
{
if ( ($this->GetUserName() == $data['postby']) || ($this->IsAdmin($this->GetUser())) )
{
$out .= " | <small><a href=\"".$this->Href("","", "&phase=del_sug&id=".$id."&delid=".$data['id'])."&title=".htmlspecialchars($data['title'])."\">Delete</a></small>";
}
}
$out .= "\n\t\t</td>\n\t</tr>";
$out .= "\n\t<tr>\n\t\t<td bgcolor=\"#999999\" width=\"5%\"></td>\n\t\t<td>".($this->Format($data['content']))."</td>\n\t</tr>";
// do the final row on this particular suggestion entry ...
$out .= "\n\t<tr>\n\t\t<td colspan=\"2\"><small>".($this->Format("//".$data['postby']." posted on ".$data['time']."//"))."</small></td>\n\t</tr>";
$out .= "\n</table>\n<hr />";
}
if ( ( ($this->HasAccess("comment")) && ($this->HasAccess("write")) )|| $this->IsAdmin())
{
$out .= "<form action=\"".$this->Href("","", "phase=reply_to&id=".$id)."\" method=\"post\">\n";
$out .= "<input type=\"hidden\" name=\"status\" value=\"".$data['status']."\">";
$out .= "\n\tTopic : <br /><textarea id=\"topic_text\" name=\"topic\" cols=\"78\"></textarea><br />";

$out .= "\n\t<label for=\"reply_text\">Add a reply to this suggestion :<br />\n\t\t";
$out .= "\n\t\t<textarea id=\"reply_text\" name=\"body\" rows=\"6\" cols=\"78\"></textarea>";
$out .= "\n\t</label><br />";

$out .= "\n\t\t<br /><small>When you are ready to submit your Reply you may press ".$this->Format("#%Alt#%+#%A#%")." or <input value=\"Add Reply\" accesskey=\"a\" type=\"submit\"/>\n\t";
$out .= $this->FormClose();
}
echo $this->ReturnSafeHTML($out);
}
/*
** ---------------------------------------------------------------------------------------------------------------------------------
** ------------------------------------------------------------------------------- DELETE REPLY
** ---------------------------------------------------------------------------------------------------------------------------------
*/
elseif ($phase == 'del_sug')
{
if ( isset($_GET['delid']) && ($_GET['delid'] != "") )
{
if ( ($this->GetUserName() == $data['postby']) || ($this->IsAdmin($this->GetUser())) )
{
$delid = $_GET['delid'];
$parent_id = $_GET['id'];
if ( ($delid == $parent_id) && ($this->IsAdmin($this->GetUser())) )
{
$msg = "The thread entitled : ".$_GET['title']." was deleted";
$url = "&phase=show_sug&id=".$parent_id;
}
else
{
$msg = "The reply to the ".( (isset($_GET['title'])) ? $_GET['title'] : 'suggestion')." was deleted.";
$url = "phase=manage_sugs";
}
$this->Query("DELETE FROM ".$this->config["table_prefix"]."suggestions WHERE (id = '".$delid."' or parent='".$delid."')");
$this->SetMessage($msg);
$this->Redirect($this->Href("","", $url));
}
}
else
{
$this->Redirect($this->Href("","", "&phase=show_sug&id=".$_GET['id']));
}
}
/*
** ---------------------------------------------------------------------------------------------------------------------------------
** ------------------------------------------------------------------------------- REPLY TO SUGGESTION
** ---------------------------------------------------------------------------------------------------------------------------------
*/
elseif ($phase == 'reply_to')
{
if ( ( ($this->HasAccess("comment")) && ($this->HasAccess("write")) )|| $this->IsAdmin())
{
if (($_POST['status'] != "I") && ($_POST['status'] != "R"))
{
$this->Query("INSERT INTO ".$this->config["table_prefix"]."suggestions (title,postby,time,status,content,parent) ".
"VALUES ('".addslashes($_POST['topic'])."', '".($this->GetUserName())."', NOW(), '".$_POST['status']."', '".addslashes($_POST['body'])."', '".$_GET['id']."')");
$this->SetMessage("The reply to the \"".( (isset($_GET['title'])) ? $_GET['title'] : 'suggestion')."\" was added." );
$this->Redirect($this->Href("","", "&phase=show_sug&id=".$_GET['id']));
}
else
{
$this->SetMessage("You can't add replies to this suggestion. Its status is set to ".GetStatusStr($sug_arr['status']));
$this->Redirect($this->Href("","", "&phase=show_sug&id=".$_GET['id']));
}
}
else
{
$this->SetMessage("You can't add replies to this suggestion, you dont have the proper privileges.");
$this->Redirect($this->Href("","", "&phase=show_sug&id=".$_GET['id']));
}
}
/*
** ---------------------------------------------------------------------------------------------------------------------------------
** ------------------------------------------------------------------------------- ADD NEW SUGGESTION THREAD
** ---------------------------------------------------------------------------------------------------------------------------------
*/
elseif ($phase == 'add_sug')
{
if ( ( ($this->HasAccess("comment")) && ($this->HasAccess("write")) )|| $this->IsAdmin())
{
if (!isset($_GET['done']))
{
$out = $this->Format("@@===New Suggestion===@@");
$out .= "<a href=\"".$this->Href("","", "phase=manage_sugs&sort=all")."\">Suggestions Index</a>";
$out .= $this->Format(">>Minimum **Topic** length is set to ".$min_topic_length." character".(($min_topic_length == 1)? '' : 's')." --- Minimum **Reply** length is set to ".$min_reply_length." character".(($min_reply_length == 1)? '' : 's').">>--- ----");
$out .= "<form action=\"".$this->Href("","", "phase=add_sug&done=1")."\" method=\"post\">\n";
$out .= "\n\tTopic : <br /><textarea id=\"topic_text\" name=\"topic\" cols=\"60\"></textarea><br />";
$out .= "\n\t<label for=\"reply_text\">Add a reply to this suggestion :<br />\n\t\t";
$out .= "\n\t\t<textarea id=\"reply_text\" name=\"body_text\" rows=\"8\" cols=\"60\"></textarea>";
$out .= "\n\t</label><br />";

$out .= "\n\t\t<br /><small>When you are ready to submit your Reply you may press ".$this->Format("#%Alt#%+#%A#%")." or <input value=\"Add New Suggestion\" accesskey=\"a\" type=\"submit\"></small>\n\t";
$out .= $this->FormClose();
echo $this->ReturnSafeHTML($out);
}
else
{
if (isset($_GET['done']) )// if the Add Reply was pressed then
{ // check if the lengths of the inputs are ok ...
$_GET['done'] = ( (strlen($_POST['topic']) >= $min_topic_length)&&(strlen($_POST['body_text']) >= $min_reply_length) )? 1 : -1;
}
else // if we reached here from smwh else than the Add Reply Button. .. (possibly a $this->Redirect)
{
$_GET['done'] = 0;
}
switch($_GET['done'])
{
case 1:
$this->Query("INSERT INTO ".$this->config['table_prefix']."suggestions( `title` , `postby` , `time` , `content` , `parent` )
VALUES ( '".addslashes($_POST['topic'])."', '".($this->GetUserName())."', now( ) , '".addslashes($_POST['body_text'])."', 0)");
$_GET['done'] = 0;
$this->SetMessage("New Suggestion Posted");
$this->Redirect($this->Href("","", "phase=manage_sug"));
break;
case -1:
$msg = "The Suggestion Topic has to be more than ".$min_topic_length." character".(($min_topic_length == 1 )?'s' : '')." long and ";
$msg .= "the Suggestion Text has to be more than ".$min_reply_length." character".(($min_reply_length == 1 )?'s' : '')." long.";
$this->SetMessage($msg);
$this->Redirect($this->Href("","", "&phase=add_sug"));
break;
default:
$this->Redirect($this->Href("","", "&phase=add_sug"));
}
}
}
}
/*
** ---------------------------------------------------------------------------------------------------------------------------------
** ------------------------------------------------------------------------------- CHANGE STATUS TO A SUGGESTION THREAD
** ---------------------------------------------------------------------------------------------------------------------------------
*/
elseif ($phase == 'chng_status')
{
if ( ($this->IsAdmin()) && ($_GET['t_id'] !== 0) )
{
$this->Query("UPDATE ".$this->config['table_prefix']."suggestions SET status='".$_GET['sug_status']."' where id=".$_GET['t_id']." or parent=".$_GET['t_id']);
$this->SetMessage("The status of ".GetTitleFromID($_GET['t_id'], $all_sugs)." is now set to ".GetStatusStr($_GET['sug_status']));
$this->Redirect($this->Href("","",( ($_GET['from_phase']=='show_sug') ? "&phase=".$_GET['from_phase']."&id=".$_GET['t_id'] : "phase=".$_GET['from_phase'] ) ));
}
else // silently redirect to the Suggestions Index ...
{
$this->Redirect($this-Href("","","phase=manage_sugs"));
}
}
?>
%%

===Usage===
You just insert ""{{msgboard}}"" inside any page. Keep in mind that posting on this is affected by the ACLS of the specific page.

===Final Note===
This is my Gift to the Wikka development to enable these wonderfull people behind Wikka to manage the Suggestions they receive ...
Happy New Year to All ;)
----//Suggestions, Modifications as well as comments are most welcome ...//----

Happy New Year to all!
- ++See my comment below for the missing "create entry function"++ I added a little bit to the code above. It should be possible now to add new topics if there are none
- I added a ".$this->config["table_prefix"]." to the first query
- changing the status of a topic does not work with mod_rewrite
- I like this modification very much :) --NilsLindenberg

----


Revision [4730]

Edited on 2005-01-17 14:29:36 by NilsLindenberg [cat. added]
Additions:
- I like this modification very much :) --NilsLindenberg
----
CategoryUserContributions
Deletions:
- I like this modification very much :) --NilsLindenberg


Revision [3957]

Edited on 2005-01-04 02:35:09 by NilsLindenberg [added ?>]
Additions:
?>
%%
===Usage===
Deletions:
}%%===Usage===


Revision [3952]

Edited on 2005-01-04 01:45:13 by NilsLindenberg [added ability to create first topic]
Additions:
{
$out = "<table><tr><td>No Suggestions yet ...</td>";
if ( $this->HasAccess("comment") || $this->HasAccess("write") || $this->IsAdmin() )
{
$out .="<tr><tr><td><a href=\"".$this->Href("","", "phase=add_sug")."\">Add Suggestion Thread</a>";
}
$out .="</td></tr></table>";
}
- ++See my comment below for the missing "create entry function"++ I added a little bit to the code above. It should be possible now to add new topics if there are none
Deletions:
$out = "<table><tr><td>No Suggestions yet ...</td><tr></table>";
- See my comment below for the missing "create entry dfunction"


Revision [3951]

Edited on 2005-01-04 01:38:05 by NilsLindenberg [further comments]
Additions:
Happy New Year to all!
- I added a ".$this->config["table_prefix"]." to the first query
- changing the status of a topic does not work with mod_rewrite
- I like this modification very much :) --NilsLindenberg
Deletions:
Happy New Year to all! --NilsLindenberg
- I added a ".$this->config["table_prefix"]." to the first query


Revision [3948]

Edited on 2005-01-04 01:23:50 by NilsLindenberg [comments]
Additions:
{{lastedit}}
----//Suggestions, Modifications as well as comments are most welcome ...//----
Happy New Year to all! --NilsLindenberg
- See my comment below for the missing "create entry dfunction"
- I added a ".$this->config["table_prefix"]." to the first query
Deletions:
----//Suggestions, Modifications as well as comments are most welcome ...//----


Revision [3947]

Edited on 2005-01-04 01:16:39 by NilsLindenberg [adding table_prefix to first query]
Additions:
$all_sugs = $this->LoadAll("SELECT * FROM ".$this->config["table_prefix"]."suggestions ORDER BY parent, time");
Deletions:
$all_sugs = $this->LoadAll("SELECT * FROM suggestions ORDER BY parent, time");


Revision [3942]

The oldest known version of this page was created on 2005-01-03 22:52:57 by GeorgePetsagourakis [adding table_prefix to first query]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki