====Wikka Mail==== The version 1.5 release is a major feature release for wikka mail. Apart from the increase in functionality (including a category/filter system, an urgent indicator, limits on submitted length in the messages w/ a counter, a "replied to" indicator, etc) there was also a database change (the addition of 5 fields and the removal of one). If you are **upgrading** from version 1.0 there are detailed instructions at the bottom of the page. The code below implements a private messaging system in wikka. It allows messages to be sent between users, a contact list to be maintained, user-defined folders for filing the messages, forwarding & replying to messages, etc. The "in-box" and "sent" folder are paginated (because they often have a high number of entries). Most of the functionality of email, with the exception of attachments & multiple recipients, are present. Optional code is provided which can be added to the header.php file providing a visual indicator to show the presence of new, unread messages. Two mysql tables need to be added, one class file (also used in the WikkaBlog2) for pagination placed in the directory "scripts" in the wikka root, and one file (mail.php) placed in the actions directory. The table prefixes should be set to match the prefix used in your wiki. %%(sql) CREATE TABLE `wakka_mail` ( `UserTo` tinytext NOT NULL, `repliedto` tinyint(1) default '0', `folder` tinytext NOT NULL, `UserFrom` tinytext NOT NULL, `urgent` tinyint(1) default NULL, `Subject` mediumtext NOT NULL, `Message` longtext NOT NULL, `fltr1` tinyint(1) default '0', `fltr2` tinyint(1) default '0', `fltr3` tinyint(1) default '0', `status` text NOT NULL, `DateSent` datetime default NULL, `viewrecipient` enum('Y','N') NOT NULL default 'Y', `mail_id` int(80) NOT NULL auto_increment, PRIMARY KEY (`mail_id`) ) TYPE=MyISAM; CREATE TABLE `wakka_mailinfo` ( `owner` tinytext NOT NULL, `type` tinytext NOT NULL, `info` tinytext NOT NULL, `notes` tinytext, `id` int(80) NOT NULL auto_increment, PRIMARY KEY (`id`) ) TYPE=MyISAM; %% This code is for ##mail.php## and should be inserted into the actions directory. %%(php) to provide an indication in the header of when there's mail. // if (mysql_num_rows(mysql_query("SELECT status FROM ".$this->config["table_prefix"]."mail where UserTo='".$this->GetUserName()."' and folder='inbox' and status='unread' and viewrecipient='Y' LIMIT 1"))!=0) {echo "*";} // includes functions for doing pagination of "sent" & "inbox" messages include_once("scripts/page.inc.php"); $pagename = $this->MiniHref($method, $tag); $link = $this->config["base_url"].$this->MiniHref($method, $tag); $userfrom = $this->GetUserName(); $pagenum=$_GET['page']; $username = $userfrom; $folder=$_GET['folder']; $which=$_REQUEST['whichfolder']; if (!$folder) {$folder=$which;} $fltrset=$_GET['fltrset']; $msg_id=$_GET['mail_id']; $filter=$_GET['fltr']; $move2folder = $_REQUEST[move2folder]; $action=$_GET['action']; $subject=$_GET[subject]; $mail_id=$msg_id; $id=$_GET['id']; $to=$_GET['to']; ?>
| Inbox | Compose | config["table_prefix"]."mailinfo WHERE type='folder' and owner='$username' ORDER BY info ASC"; $resultdrop = mysql_query($str); echo "
"; ?>
| Sent | Manage Folders / Contacts | Users | Help |
In-box";} elseif ($action=="sent" || $action=="view2") {$which2="Sent Mail";} elseif (folder!="") {$which=$folder; $which2="".$which."";} echo "Folder:  ".$which2; } // code for moving messages to folders if ($move2folder) { $query="UPDATE ".$this->config["table_prefix"]."mail SET folder='$move2folder' WHERE UserTo='$username' AND mail_id='$mail_id'"; $query or die("An error occurred resulting that this message has not been marked read."); $rs = mysql_query("UPDATE ".$this->config["table_prefix"]."mail SET folder='$move2folder' WHERE mail_id='$mail_id' AND UserTo='$username'"); if($query) { echo "
Message moved to ".$move2folder." folder."; } else { echo "The message wasn't moved."; } } // shows inbox elseif(($action=='' || $action=='inbox') && $_REQUEST['whichfolder']=='' && (!$folder)) { if ($filter==1) {$search="and fltr1='1' ";} elseif ($filter==2) {$search="and fltr2='1' ";} elseif ($filter==3) {$search="and fltr3='1' ";} elseif ($filter==N) {$search="and fltr1='0' and fltr2='0' and fltr3='0' ";} else {$search="";} // setting the filter conditions into the database $queryfil="SELECT fltr1,fltr2,fltr3,mail_id FROM ".$this->config["table_prefix"]."mail where UserTo='$username' and folder='inbox' and viewrecipient='Y' ORDER BY DateSent DESC"; $resultfil=mysql_query($queryfil) or die ("cant do it"); while ($row=mysql_fetch_array($resultfil)) { // code to set filters in database if (($fltrset) && ($row[mail_id]==$msg_id)) { // code to determine setting of filters on server if ($row[fltr1]!=1) {$fltrvar1=1;} else {$fltrvar1=0;} if ($row[fltr2]!=1) {$fltrvar2=1;} else {$fltrvar2=0;} if ($row[fltr3]!=1) {$fltrvar3=1;} else {$fltrvar3=0;} // code to set which filter is being set if ($fltrset==1) {$fltr="fltr1"; $set=$fltrvar1;} elseif ($fltrset==2) {$fltr="fltr2"; $set=$fltrvar2;} elseif ($fltrset==3) {$fltr="fltr3"; $set=$fltrvar3;} mysql_query("UPDATE ".$this->config["table_prefix"]."mail SET ".$fltr."=".$set." WHERE mail_id='$msg_id' AND UserTo='$username'"); } } $query="SELECT * FROM ".$this->config["table_prefix"]."mail where UserTo='$username' ".$search."and folder='inbox' and viewrecipient='Y' ORDER BY DateSent DESC"; $result=mysql_query($query) or die ("cant do it"); echo ""; //needed for pagination of sent box $record_per_page=10; $scroll=3; $total_records=mysql_num_rows($result); $page=new Page(); //creating new instance of Class Page $link2=$link."&action=inbox"; // to paginate the "inbox" page messages echo ""; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; while ($row=mysql_fetch_array($result)) { // Extracting & formatting date $datetime=date("dMy g:i a",strtotime($row['DateSent'])); // put in red asterisk if unread & add coloured filters if ($row[status]=="unread") {$status="*";} else {$status="";} if ($row[urgent]=="1") {$urgentmkr="!";} else {$urgentmkr="";} if ($row[repliedto]=="1") {$replied="+";} else {$replied=" ";} echo ""; echo ""; echo ""; } echo "
"; if ($total_records>$record_per_page) { $page->set_page_data($link2,$total_records,$record_per_page,$scroll,true,true,true); $result=mysql_query($page->get_limit_query($query)); echo $page->get_page_nav(); } echo "
 Message Topic:"; // sets underline on filter if chosen if ($filter==1) {$red="*";} else {$red="*";} if ($filter==2) {$blue="*";} else {$blue="*";} if ($filter==3) {$green="*";} else {$green="*";} if ($filter=="N") {$none="N";} else {$none="N";} echo "A ".$none." ".$red." "; echo "".$blue." ".$green."
 Sender: Move to Folder: Delete:  +/-
$status$urgentmkr ".strip_tags($row[Subject])."".$replied."(".$datetime.")"; // put in asterisks if indicated to do so in database if ($row[fltr1]==1) {echo "*";} else {echo "  ";} if ($row[fltr2]==1) {echo "*";} else {echo "  ";} if ($row[fltr3]==1) {echo "*";} else {echo "  ";} echo "".$this->Format($row[UserFrom])." [->]"; // code to put in drop down box to move to a new folder $str2 = "SELECT DISTINCT info FROM ".$this->config["table_prefix"]."mailinfo WHERE type='folder' and owner='$username' ORDER BY info ASC"; $resultdrop2 = mysql_query($str2); echo "
"; echo "
[Delete]
 *|*|*
"; if ($total_records!=0) { echo "   Clicking on the right arrow indicator [->] will add the user's name to the \"contacts\" list.
   A \"+\" sign to the right of the message title indicates that you have replied to the message.
"; }else{ echo "
There are no currently no messages in the in-box
(or, none meet the requirements of the applied filter).


"; } } // send a new message to a user elseif($action==compose) { $subject2=$_GET[subject]; echo "Compose a message...."; echo "
"; echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
Subject:
To:
Message:
characters left.
Urgent?
All fields must have content.
"; echo "
"; echo "
"; echo "Contact List
(click on name to add to form)
"; $cntctresult = mysql_query("SELECT info FROM ".$this->config["table_prefix"]."mailinfo WHERE type='contact' and owner='$username' ORDER BY info ASC"); while ($row=mysql_fetch_array($cntctresult)) { echo "".$row['info']."
"; } echo "
"; } // send a reply to message sender elseif($action==reply) { $subject2=$_GET[subject]; echo "Reply to the message...."; echo ""; echo ""; $result=mysql_query("SELECT * from ".$this->config["table_prefix"]."mail WHERE UserTo='$username' AND mail_id=$mail_id") or die ("cant do it"); $rowreply=mysql_fetch_array($result); $origmsg=" \n \n++++++++++ Original Message ++++++++++\n".strip_tags($rowreply[Message])."\n+++++++++++++++++++++++++++++++++"; echo ""; echo ""; echo "
"; echo "
"; echo "
Subject:
To:
Message:
characters left.
Urgent?
All fields must have content.
"; echo ""; } // send a forwarded message elseif($action==forward && $mail_id!="") { $username = $this->GetUserName(); echo "Add a message to the forwarded message...."; echo "
"; echo "
"; echo ""; $subject2 = "FWD: ".$subject; echo ""; echo ""; $result=mysql_query("SELECT * from ".$this->config["table_prefix"]."mail WHERE UserTo='$username' AND mail_id=$mail_id") or die ("cant do it"); $rowfwd=mysql_fetch_array($result); $origmsg=" \n \n++++++++++++ Forward ++++++++++++++\n".strip_tags($rowfwd[Message])."\n+++++++++++++++++++++++++++++++++"; echo ""; echo ""; echo "
Subject:
To:
Message:
characters left.
Urgent?
All fields must have content.
"; echo "
"; echo "
"; echo "Contact List
(click on name to add to form)
"; $cntctresult = mysql_query("SELECT info FROM ".$this->config["table_prefix"]."mailinfo WHERE type='contact' and owner='$username' ORDER BY info ASC"); while ($row=mysql_fetch_array($cntctresult)) { echo "".$row['info']."
"; } echo "
"; } // enters message from compose window (original or forward) into the database if($action==compose2) { if ($user = $this->GetUser()){ $urgent=$_POST['urgent']; $to=$_POST['to']; $to=addslashes($to); $subject=$_POST['subject']; $subject=addslashes($subject); $message=$_POST['message']; $message=strip_tags($message); $message=addslashes($message); $replyto=$_GET['replyto']; $date = date(YmdHis); // check if user exists & if so sends message if($subject=="" || $message=="" || $to==""){ echo "One of the fields was left blank."; }else{ if($this->LoadUser($to)) { $create = "INSERT INTO ".$this->config["table_prefix"]."mail (UserTo, folder, UserFrom, Subject, Message, DateSent, status, urgent) VALUES ('$to','inbox','$username','$subject','$message','$date','unread','$urgent')"; $create2 = mysql_query($create) or die("A letter could not be sent to $to!"); echo("Message Sent to $to!






"); //to set the database so that the message has been replied to mysql_query("UPDATE ".$this->config["table_prefix"]."mail SET repliedto='1' WHERE mail_id='$replyto' AND UserTo='$username'"); } else { echo "The recipient name entered was not a registered user.
You might check the upper/lower case of the spelling."; } } }else{ echo "
You must be both registered and logged in to use this Private Messaging System.
"; } } // show sent box elseif($action=='sent') { $query="SELECT * from ".$this->config["table_prefix"]."mail where UserFrom='$username' ORDER BY DateSent DESC"; $result=mysql_query($query) or die ("cant do it"); echo ""; //needed for pagination of sent box $record_per_page=12; $total_records=mysql_num_rows($result); $scroll=3; $page=new Page(); //creating new instance of Class Page $link2=$link."&action=sent"; $page->set_page_data($link2,$total_records,$record_per_page,$scroll,true,true,true); $result=mysql_query($page->get_limit_query($query)); // to paginate the "sent" page messages echo ""; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; while ($row=mysql_fetch_array($result)) { $datetime=date("dMy g:i a",strtotime($row['DateSent'])); echo ""; } echo "
"; if ($total_records>$record_per_page) {echo $page->get_page_nav();} echo "
 Message Topic: Sent to: Read?
".strip_tags($row[Subject])." (".$datetime.")".$this->Format($row[UserTo])." [->] $row[status]
"; echo "   Clicking on the right arrow indicator [->] will add the user's name to the \"contacts\" list."; } // Code to show folders according to selection elseif((($_REQUEST['whichfolder']!='') || ($folder)) && ($action!=view)) { if ($filter==1) {$search="and fltr1='1' ";} elseif ($filter==2) {$search="and fltr2='1' ";} elseif ($filter==3) {$search="and fltr3='1' ";} elseif ($filter==N) {$search="and fltr1='0' and fltr2='0' and fltr3='0' ";} else {$search="";} if ($_REQUEST['whichfolder']!='') {$showfolder = $_REQUEST['whichfolder'];} else {$showfolder=$folder;} echo ""; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; $query="SELECT fltr1,fltr2,fltr3,mail_id FROM ".$this->config["table_prefix"]."mail where UserTo='$username' ".$search."and folder='$folder' and viewrecipient='Y' ORDER BY DateSent DESC"; $result=mysql_query($query) or die ("cant do it"); while ($row=mysql_fetch_array($result)) { // code to set filters in database if (($fltrset) && ($row[mail_id]==$msg_id)) { // code to determine setting of filters on server if ($row[fltr1]!=1) {$fltrvar1=1;} else {$fltrvar1=0;} if ($row[fltr2]!=1) {$fltrvar2=1;} else {$fltrvar2=0;} if ($row[fltr3]!=1) {$fltrvar3=1;} else {$fltrvar3=0;} // code to set which filter is being set if ($fltrset==1) {$fltr="fltr1"; $set=$fltrvar1;} elseif ($fltrset==2) {$fltr="fltr2"; $set=$fltrvar2;} elseif ($fltrset==3) {$fltr="fltr3"; $set=$fltrvar3;} mysql_query("UPDATE ".$this->config["table_prefix"]."mail SET ".$fltr."=".$set." WHERE mail_id='$msg_id' AND UserTo='$username'"); } } $result=mysql_query("SELECT * from ".$this->config["table_prefix"]."mail where UserTo='$username' ".$search."AND folder='$showfolder' ORDER BY DateSent DESC") or die ("cant do it"); $numrows=mysql_num_rows($result); while ($row=mysql_fetch_array($result)) { $datetime=date("dMy g:i a",strtotime($row['DateSent'])); if ($row[status]=="unread") {$status="*";} else {$status="";} if ($row[urgent]=="1") {$urgentmkr="!";} else {$urgentmkr="";} if ($row[repliedto]=="1") {$replied="+";} else {$replied=" ";} echo ""; echo ""; } echo "
 Message Topic:"; if ($filter==1) {$red="*";} else {$red="*";} if ($filter==2) {$blue="*";} else {$blue="*";} if ($filter==3) {$green="*";} else {$green="*";} if ($filter=="N") {$none="N";} else {$none="N";} echo "A ".$none." ".$red." "; echo "".$blue." ".$green."
 Sender: Move to Folder: Delete:  +/-
$status$urgentmkr ".strip_tags($row[Subject])."".$replied."(".$datetime.")"; // put in asterisks if indicated to do so in database if ($row[fltr1]==1) {echo "*";} else {echo "  ";} if ($row[fltr2]==1) {echo "*";} else {echo "  ";} if ($row[fltr3]==1) {echo "*";} else {echo "  ";} echo "".$this->Format($row[UserFrom])." [->]"; // code to put in drop down box to move to a new folder $str2 = "SELECT DISTINCT info FROM ".$this->config["table_prefix"]."mailinfo WHERE type='folder' and owner='$username' ORDER BY info ASC"; $resultdrop2 = mysql_query($str2); echo "
"; echo "
[Delete]
 *|*|*
"; if ($numrows==0) {echo "
There are no messages currently stored
in this folder (or, with this filter).


"; } } // view individual email messages elseif($action==view) { $result=mysql_query("select * from ".$this->config["table_prefix"]."mail where UserTo='$username' and mail_id=$msg_id") or die ("cant do it"); $row=mysql_fetch_array($result); if (($fltrset) && ($row[mail_id]==$msg_id)) { // code to determine setting of filters on server if ($row[fltr1]!=1) {$fltrvar1=1;} else {$fltrvar1=0;} if ($row[fltr2]!=1) {$fltrvar2=1;} else {$fltrvar2=0;} if ($row[fltr3]!=1) {$fltrvar3=1;} else {$fltrvar3=0;} // code to set which filter is being set if ($fltrset==1) {$fltr="fltr1"; $set=$fltrvar1;} elseif ($fltrset==2) {$fltr="fltr2"; $set=$fltrvar2;} elseif ($fltrset==3) {$fltr="fltr3"; $set=$fltrvar3;} mysql_query("UPDATE ".$this->config["table_prefix"]."mail SET ".$fltr."=".$set." WHERE mail_id='$msg_id' AND UserTo='$username'"); } $result=mysql_query("select * from ".$this->config["table_prefix"]."mail where UserTo='$username' and mail_id=$msg_id") or die ("cant do it"); $row=mysql_fetch_array($result); $username=strtolower($username); $row[UserTo]=strtolower($row[UserTo]); if ($row[repliedto]=="1") {$replied="replied to";} else {$replied=" ";} // code to set filters in database if($row[UserTo]==$username) { $query="UPDATE ".$this->config["table_prefix"]."mail SET status='read' WHERE UserTo='$username' AND mail_id='$row[mail_id]'"; $query or die("An error occurred resulting that this message has not been marked read."); $datetime=date("dMy g:i a",strtotime($row['DateSent'])); echo ""; echo "
Subject: ".strip_tags($row[Subject])." "; // put in asterisks if indicated to do so in database if ($row[fltr1]==1) {echo "*";} else {echo "  ";} if ($row[fltr2]==1) {echo "*";} else {echo "  ";} if ($row[fltr3]==1) {echo "*";} else {echo "  ";} echo ""; echo " *|*|*"; echo "From: ".$this->Format($row[UserFrom])." [->]
Message: ".strip_tags($row[Message])."
Reply / Forward"; echo " / Delete".$replied."Sent: $datetime

"; $rs = mysql_query("UPDATE ".$this->config["table_prefix"]."mail SET status='read' WHERE mail_id='$msg_id'"); } else { echo "This isn't your mail!"; } echo "   Clicking on the right arrow indicator [->] will add the sender's name to the \"contacts\" list."; } // added filter for viewing "folder sorted" mail elseif($action==view2) { $result=mysql_query("SELECT * from ".$this->config["table_prefix"]."mail where UserFrom='$username' and mail_id='$msg_id'") or die ("cant do it"); $row=mysql_fetch_array($result); $username=strtolower($username); $userfrom=strtolower($row[UserFrom]); if($userfrom==$username) { $datetime=date("dMy g:i a",strtotime($row['DateSent'])); echo ""; echo "
Subject: ".strip_tags($row[Subject])."
Recipient: ".$this->Format($row[UserTo])." [->]
Message: $row[Message]
Sent: ".$datetime."
"; } echo "   Clicking on the right arrow indicator [->] will add the sender's name to the \"contacts\" list."; } // DELETE code for messages (now updates so that message is not visible instead of deleting) elseif($action==delete) { $query="UPDATE ".$this->config["table_prefix"]."mail SET viewrecipient='N' WHERE UserTo='$username' AND mail_id='$id'"; $query or die("An error occurred resulting that this message has not been marked read."); $rs = mysql_query("UPDATE ".$this->config["table_prefix"]."mail SET viewrecipient='N' WHERE mail_id='$id'"); if($query) { echo "Message was deleted.






"; } else { echo "The message was not deleted."; } } // code to manage contact list elseif ($action==contacts){ $addcontact=$_GET['cntct']; $table = $this->config["table_prefix"]."mailinfo"; $field1 = "info"; $field1_label = "Contact Names"; $field2 = "notes"; $field2_label = "Notes"; $deletecnt = $_GET['deletecnt']; $field1_value=$_POST['field1_value']; if ($field1_value) {$insert="1";} else {$insert="";} $field2_value=$_POST['field2_value']; $category="contact"; if ($user = $this->GetUser()){ if ($insert) { if($this->LoadUser($field1_value)) { mysql_query( "INSERT into $table ($field1, $field2, owner, type) values (\"$field1_value\",\"$field2_value\",\"$username\",\"$category\")"); } } if ($deletecnt) { mysql_query( "DELETE from $table WHERE id=$deletecnt AND owner='$username'"); } if (mysql_errno()!=0) { switch (mysql_errno()) { default: echo "Error #".mysql_errno(). " (".mysql_error(). ")
"; } } } $query = "SELECT * from $table WHERE owner='$username' AND type='$category' ORDER BY info ASC"; $result = mysql_query($query); $rows = mysql_num_rows($result); echo "Contact Management"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; // This is the entry boxes echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; // This is the data under the entry boxes while ($row = mysql_fetch_row($result)) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; } echo "
$field1_label$field2_label 
"; echo "
".$row[2]."  [Home Page]".strip_tags($row[3])."
Delete
"; echo "Clicking on the contact name will take you to message entry screen."; } // code to manage folder list elseif ($action==folders){ $table = $this->config["table_prefix"]."mailinfo"; $field1 = "info"; $field1_label = "Folder List"; $field2 = "notes"; $field2_label = "Notes"; $deletefldr = $_GET['deletefldr']; $fldr = $_GET['fldr']; $field1_value=$_POST['field1_value']; if ($field1_value) {$insert="1";} else {$insert="";} $field2_value=$_POST['field2_value']; $category="folder"; if ($user = $this->GetUser()){ if ($insert) { mysql_query( "INSERT into $table ($field1, $field2, owner, type) values (\"$field1_value\",\"$field2_value\",\"$username\",\"$category\")"); } if ($deletefldr) { // delete folder name from mailinfo mysql_query("DELETE from $table WHERE id='$deletefldr' AND owner='$username' AND type='folder'"); // change files from being stored in folder being deleted to being stored in inbox mysql_query("UPDATE ".$this->config["table_prefix"]."mail SET folder='inbox' WHERE folder='$fldr' AND UserTo='$username'"); } if (mysql_errno()!=0) { switch (mysql_errno()) { default: echo "Error #".mysql_errno(). " (".mysql_error(). ")
"; } } } $query = "SELECT * from $table WHERE owner='$username' AND type='$category' ORDER BY info ASC"; $result = mysql_query($query); $rows = mysql_num_rows($result); echo "Folder Management"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; // This is the entry boxes echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; // This is the data under the entry boxes while ($row = mysql_fetch_row($result)) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } echo "
$field1_label$field2_label 
"; echo "
".strip_tags($row[2])."".strip_tags($row[3])."
Delete
"; echo "Clicking on the folder name will take you to that folder."; } // code to display user list elseif ($action==users){ echo "
"; $last_users = $this->LoadAll("select name from ".$this->config["table_prefix"]."users order by name ASC"); echo "User List. Click on the name to add it to the contact list.
"; foreach($last_users as $user) { echo "".$user["name"]." "; } echo "
"; } //code to show brief instructions for using filters elseif ($action==help){ echo "
"; echo "

An introduction to sending messages in Wikka...

"; echo "There are two brief parts to this help file. The first is how to interpret the output screen. The second is a description of how filters work.

"; echo "     Introduction to the output...

"; echo "Below is a typical output line in the In-Box, Folder lists or the Sent message area.

"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
"; echo "

 !* Science Class tomorrow (05Feb05 2:08 pm)*  *

"; echo "
"; echo "

GmBowen [->]

"; echo "
"; echo "

"; echo "

"; echo "

"; echo "
"; echo "

[Delete]

"; echo "
"; echo "

 *|*|*
"; echo "

"; echo "
"; echo "
Here is how to interpret the output....

"; echo "
    "; echo "
  • The exclamation mark (!) tells you that the sender marked the message urgent.
  • "; echo "
  • The first red star (*) tells you that you have not read the message yet.
  • "; echo "
  • 'Science Class tomorrow' is the topic of the message.
  • "; echo "
  • If there were a plus sign (+) immediately after the topic you would know that you had replied to the message.
  • "; echo "
  • The date/time after the message lets you know when the message was sent.
  • "; echo "
  • The coloured stars after the date/time ( *) indicate that you've applied those two markers to your message (see below).
  • "; echo "
  • 'GmBowen' is the sender of the message.
  • "; echo "
  • The [->] allows you to put the senders name into your contact list.
  • "; echo "
  • The dropdown menu (starting with 'ColeBowen') is a list of folders that you can file the message into.
  • "; echo "
  • The [Delete] button allows you to delete the message (even though it does stay in the database).
  • "; echo "
  • Clicking on the three coloured stars (*|*|*) allow you to set markers on your messages.
  • "; echo "
"; echo "

"; echo "     Introduction to filters...

"; echo "

'Filters' are a simple-to-use tool that can help you organize your\n"; echo "messages.

\n"; echo "\n"; echo "

When you're in the in-box or any of the folders, on the top right\n"; echo "of the title bar you'll see a +/- with\n"; echo "*|*|*\n"; echo "underneath it (and to the right of each message). By clicking\n"; echo "on these three coloured stars you can place or remove coloured stars\n"; echo "from beside the message title. A similar feature is found inside each\n"; echo "individual message box (seen when you're reading your messages).

\n"; echo "\n"; echo "

The different colours can mean anything you want them to. Red\n"; echo "might mean 'really important' and green might mean 'Ignore for now'.\n"; echo "It's really up to you. They can mean different things to you in your\n"; echo "in-box versus your different folders as well

\n"; echo "\n"; echo "

\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; echo "

\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; echo "

 Message Topic:

\n"; echo "
\n"; echo "

A N * * *

\n"; echo "
\n"; echo "

\n"; echo "
\n"; echo "

 Sender:

\n"; echo "
\n"; echo "

 Move to Folder:

\n"; echo "
\n"; echo "

 Delete:

\n"; echo "
\n"; echo "

  +/-

\n"; echo "
\n"; echo "

\n"; echo "\n"; echo "

On the grey title bar to the right of 'Message Topic:' you can see\n"; echo " A N \n"; echo "* * *

\n"; echo "\n"; echo "

By clicking on the 'A' you'll see all of the messages,\n"; echo "on the 'N' you'll see the messages that don't have any markers\n"; echo "beside them, and if you click on any of the coloured stars you'll see\n"; echo "the messages that have those coloured markers beside them.

\n"; echo "\n"; echo "

Easy eh? 

\n"; echo "
"; } ?> %% The following file should be saved as ##page.inc.php## in a directory called ##scripts## in the wikka root.... %%(php) page>=$this->total_page-1?true:false; } /* param : Void returns boolean value if it is first page or not*/ function is_first_page() { return $this->page==0?true:false; } function current_page() { return $this->page+1; } function total_page() { return $this->total_page==0?1:$this->total_page; } //@param : $show = if you want to show disabled links on navigation links. // function show_disabled_links($show=TRUE) { $this->show_disabled_links=$show; } //@param : $link_para = if you want to pass any parameter to link // function set_link_parameter($link_para) { $this->link_para=$link_para; } function set_page_name($page_name) { $this->page_name=$page_name; } //@param : str= query string you want to pass to links. function set_qry_string($str="") { $this->qry_str="&".$str; } function set_scroll_page($scroll_num=0) { if($scroll_num!=0) $this->scroll_page=$scroll_num; else $this->scroll_page=$this->total_records; } function set_total_records($total_records) { if($total_records<0) $total_records=0; $this->total_records=$total_records; } function set_records_per_page($records_per_page) { if($records_per_page<=0) $records_per_page=$this->total_records; $this->records_per_page=$records_per_page; } /* @params * $page_name = Page name on which class is integrated. i.e. $_SERVER['PHP_SELF'] * $total_records=Total records returnd by sql query. * $records_per_page=How many projects would be displayed at a time * $scroll_num= How many pages scrolled if we click on scroll page link. * i.e if we want to scroll 6 pages at a time then pass argument 6. * $show_prev_next= boolean(true/false) to show prev Next Link * $show_scroll_prev_next= boolean(true/false) to show scrolled prev Next Link * $show_first_last= boolean(true/false) to show first last Link to move first and last page. */ function set_page_data($page_name,$total_records,$records_per_page=1,$scroll_num=0,$show_prev_next=true,$show_scroll_prev_next=false,$show_first_last=false) { $this->set_total_records($total_records); $this->set_records_per_page($records_per_page); $this->set_scroll_page($scroll_num); $this->set_page_name($page_name); $this->show_prev_next=$show_prev_next; $this->show_scroll_prev_next=$show_scroll_prev_next; $this->show_first_last=$show_first_last; } /* @params * $user_link= if you want to display your link i.e if you want to user '>>' instead of [first] link then use Page::get_first_page_nav(">>") OR for image Page::get_first_page_nav("first") $link_para: link parameters i.e if you want ot use another parameters such as class. Page::get_first_page_nav(">>","class=myStyleSheetClass") */ function get_first_page_nav($user_link="",$link_para="") { if($this->total_page<=1) return; if(trim($user_link)=="") $user_link="««  "; if(!$this->is_first_page()&& $this->show_first_last) echo ' '.$user_link.' '; elseif($this->show_first_last && $this->show_disabled_links) echo $user_link; } function get_last_page_nav($user_link="",$link_para="") { if($this->total_page<=1) return; if(trim($user_link)=="") $user_link="  »»"; if(!$this->is_last_page()&& $this->show_first_last) echo ' '.$user_link.' '; elseif($this->show_first_last && $this->show_disabled_links) echo $user_link; } function get_next_page_nav($user_link="",$link_para="") { if($this->total_page<=1) return; if(trim($user_link)=="") $user_link=" »"; if(!$this->is_last_page()&& $this->show_prev_next) echo ' '.$user_link.' '; elseif($this->show_prev_next && $this->show_disabled_links) echo $user_link." "; } function get_prev_page_nav($user_link="",$link_para="") { if($this->total_page<=1) return; if(trim($user_link)=="") $user_link="« "; if(!$this->is_first_page()&& $this->show_prev_next) echo ' '.$user_link.' '; elseif($this->show_prev_next && $this->show_disabled_links) echo " ".$user_link; } function get_scroll_prev_page_nav($user_link="",$link_para="") { if($this->scroll_page>=$this->total_page) return; if(trim($user_link)=="") $user_link="[-$this->scroll_page]"; if($this->page>$this->scroll_page &&$this->show_scroll_prev_next) echo ' '.$user_link.' '; elseif($this->show_scroll_prev_next && $this->show_disabled_links) echo $user_link; } function get_scroll_next_page_nav($user_link="",$link_para="") { if($this->scroll_page>=$this->total_page) return; if(trim($user_link)=="") $user_link="[+$this->scroll_page]"; if($this->total_page>$this->page+$this->scroll_page &&$this->show_scroll_prev_next) echo ' '.$user_link.' '; elseif($this->show_scroll_prev_next && $this->show_disabled_links) echo $user_link; } function get_number_page_nav($link_para="") { $j=0; $scroll_page=$this->scroll_page; if($this->page>($scroll_page/2)) $j=$this->page-intval($scroll_page/2); if($j+$scroll_page>$this->total_page) $j=$this->total_page-$scroll_page; if($j<0) $i=0; else $i=$j; for(;$i<$j+$scroll_page && $i<$this->total_records;$i++) { if($i==$this->page) echo ($i+1); else echo ' '.($i+1).' '; } } function get_page_nav() { if($this->total_records<=0) { //echo "No Records Found"; // return false; } $this->calculate(); $this->get_first_page_nav("",$this->link_para); $this->get_scroll_prev_page_nav("",$this->link_para); $this->get_prev_page_nav("",$this->link_para); $this->get_number_page_nav($this->link_para); $this->get_next_page_nav("",$this->link_para); $this->get_scroll_next_page_nav("",$this->link_para); $this->get_last_page_nav("",$this->link_para); // return true; } function calculate() { $this->page=$_REQUEST['page']; if(!is_numeric($this->page)) $this->page=0; $this->start=$this->page*$this->records_per_page; $this->total_page=@intval($this->total_records/$this->records_per_page); if($this->total_records%$this->records_per_page!=0) $this->total_page++; } function get_limit_query($qry="") { $this->calculate(); return $qry." LIMIT $this->start,$this->records_per_page"; } } ?> %% ---- **To upgrade your mail.php from version 1.0 to 1.5 do the following.....** 1) Use the following mysql statements (in your fvaourite mysql administration program, or at the command line if you know how) to update the table structure in your wikki database. Make sure you change "WAKKAPREFIX" to the prefix you use in your wikka. ALTER TABLE `WAKKAPREFIX_mail` ADD `repliedto` TINYINT (1) DEFAULT '0' AFTER `Message` , ADD `urgent` TINYINT (1) DEFAULT NULL AFTER `repliedto` , ADD `fltr1` TINYINT (1) DEFAULT '0' NOT NULL AFTER `urgent` , ADD `fltr2` TINYINT (1) DEFAULT '0' NOT NULL AFTER `fltr1` , ADD `fltr3` TINYINT (1) DEFAULT '0' NOT NULL AFTER `fltr2` , ADD `DateSent` DATETIME NOT NULL AFTER `fltr3` 2) THEN RUN THE PHP SCRIPT mailupdate.php as an ACTION (you can only do this as a designated administrator). Save the php code below as mailupdate.php, insert on a page, and then click on the visible link. This will alter the date code from a text string to a mysql DATETIME string (makes it easier to display date & time). %%(php) if ($this->IsAdmin()) { $link = $this->config["base_url"].$this->MiniHref($method, $tag); echo "Update database for mail.php from version 1.0 to version 1.5"; $action=$_GET['action']; if($action==update){ $query="SELECT SentDate,DateSent FROM ".$this->config["table_prefix"]."mail"; $result=mysql_query($query) or die ("cant do it"); while ($row=mysql_fetch_array($result)) { $newdate=$row[SentDate]; mysql_query("UPDATE ".$this->config["table_prefix"]."mail SET DateSent=$newdate WHERE SentDate=$newdate"); } if ($_GET['action']) {echo "Database update complete.";} } } %% Erase the update file from you actions directory. 3) Then install the new mail.php file. (erase the old one, replace with the new one.) You may or may want to put your wiki into "administrative mode" so that others cannot use it while you do this. (See these [[http://wikka.jsnx.com/UpgradeNotes notes]] for upgrading wikka.) 4) Finally, remove the ""SentDate"" field from the mysql table WAKKAPREFIX_mail using the following command. (Make sure you change "WAKKAPREFIX" to the prefix you use in your wikka.) ALTER TABLE `WAKKAPREFIX_mail` DROP `SentDate` That's it. This upgrade sequence has been tested on two sites and worked without a problem. ---- ===Action to display number of new messages waiting=== %% MiniHref($method, $tag); $link = $this->config["base_url"].$this->MiniHref($method, $tag); $username = $this->GetUserName(); $query="SELECT * FROM ".$this->config["table_prefix"]."mail where UserTo='".$username."' and status='unread'"; $result=mysql_query($query) or die ("cant do it"); $num_rows = mysql_num_rows($result); echo "(".$num_rows.")"; ?> %% I've then put this action in my wikka.config.php on the logged_in_navigation_links; %% :: {{image alt="Private Messages" title="Private Messages" url="images/email.gif" link="PrivateMessages"}} {{newmail}} :: %% --DaveFullard ---- CategoryUserContributions